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

Code generator for weak delegate wrappers More...

Static Public Member Functions

static TDelegate Wrap< TDelegate > (TDelegate method, Action ifGone)
 Wrap a given method with a weak delegate. This will allow the target of the delegate to become disposed without the wrapped delegate itself being disposed. Will call ifGone if we attempt to invoke the delegate and the target is no longer alive. More...
 
static TDelegate Wrap< TDelegate > (TDelegate method)
 Wrap a given method with a weak delegate. This will allow the target of the delegate to become disposed without the wrapped delegate itself being disposed. Will throw ObjectDisposedException if the method is no longer alive More...
 

Detailed Description

Code generator for weak delegate wrappers

Member Function Documentation

static TDelegate pluginbase.Objects.Libs.Events.WeakDelegate.Wrap< TDelegate > ( TDelegate  method,
Action  ifGone 
)
static

Wrap a given method with a weak delegate. This will allow the target of the delegate to become disposed without the wrapped delegate itself being disposed. Will call ifGone if we attempt to invoke the delegate and the target is no longer alive.

Parameters
methodMethod to wrap in the weak delegate
ifGoneAction to call if the target no longer is alive
Template Parameters
TDelegateThe wrapped delegate
Type Constraints
TDelegate :class 
68  : class
69  {
70  var realDelegate = method as Delegate;
71  if (realDelegate == null)
72  throw new InvalidOperationException("Method is not of type delegate");
73 
74  return Wrap<TDelegate>(realDelegate.Target, realDelegate.Method, ifGone);
75  }
static TDelegate pluginbase.Objects.Libs.Events.WeakDelegate.Wrap< TDelegate > ( TDelegate  method)
static

Wrap a given method with a weak delegate. This will allow the target of the delegate to become disposed without the wrapped delegate itself being disposed. Will throw ObjectDisposedException if the method is no longer alive

Parameters
methodMethod to wrap
Template Parameters
TDelegateWrapped delegate
Type Constraints
TDelegate :class 
85  : class
86  {
87  return Wrap(method, () => { throw new ObjectDisposedException("Target"); });
88  }

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