Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Objects.Libs.Events.WeakDelegateExtensions Class Reference

Static Public Member Functions

static WeakDelegate< TDelegate > AddWeak< TDelegate > (this ManagedEvent< TDelegate > managedEvent, TDelegate method)
 Add a method to a managed event using weak binding, so if the target goes out of scope, it will be let go More...
 

Member Function Documentation

static WeakDelegate<TDelegate> pluginbase.Objects.Libs.Events.WeakDelegateExtensions.AddWeak< TDelegate > ( this ManagedEvent< TDelegate >  managedEvent,
TDelegate  method 
)
static

Add a method to a managed event using weak binding, so if the target goes out of scope, it will be let go

Returns
The weak wrapper
Parameters
managedEventManaged event.
methodMethod.
Template Parameters
TDelegateThe type of the delegate
Type Constraints
TDelegate :class 
15  : class
16  {
17  var weak = new WeakDelegate<TDelegate>(method);
18  weak.OnGone += dlg => managedEvent.Remove(weak.Invoke);
19  managedEvent.Add(weak.Invoke);
20  return weak;
21  }

The documentation for this class was generated from the following file: