KS.Reactor.ksEvent< E, T > Class Template Reference

Wraps a C# event for the delegate T to allow event references. More...

Inheritance diagram for KS.Reactor.ksEvent< E, T >:
KS.Reactor.ksIEvent KS.Reactor.ksEvent< ksEvent< T >, T >

Public Member Functions

delegate void ForEachCallback (T item)
 Iterator callback used with ForEach(ForEachCallback) More...
 
delegate bool ForEachCancellableCallback (T item)
 Iterator callback that can cancel iteration by returning false. More...
 
virtual void Add (T item)
 Adds an item to the event list. More...
 
virtual void Remove (T item)
 Remove an item from the event list. More...
 
virtual void ForEach (ForEachCallback callback)
 Iterate and invoke the callback on all items. More...
 
virtual bool ForEach (ForEachCancellableCallback callback)
 Iterate and invoke the callback on all items. More...
 
- Public Member Functions inherited from KS.Reactor.ksEvent< ksEvent< T >, T >
delegate void ForEachCallback (T item)
 Iterator callback used with ForEach(ForEachCallback) More...
 
delegate bool ForEachCancellableCallback (T item)
 Iterator callback that can cancel iteration by returning false. More...
 

Static Public Member Functions

static E operator+ (ksEvent< E, T > lhs, T rhs)
 Adds an event handler to the event. More...
 
static E operator- (ksEvent< E, T > lhs, T rhs)
 Adds an event handler to the event. More...
 
- Static Public Member Functions inherited from KS.Reactor.ksEvent< ksEvent< T >, T >
static E operator+ (ksEvent< E, T > lhs, T rhs)
 Adds an event handler to the event. More...
 
static E operator- (ksEvent< E, T > lhs, T rhs)
 Adds an event handler to the event. More...
 

Protected Attributes

List< T > m_handlers = new List<T>()
 
- Protected Attributes inherited from KS.Reactor.ksEvent< ksEvent< T >, T >
List< T > m_handlers
 

Properties

int Count [get]
 The number of registered event handlers. More...
 
Execute [get]
 Gets a delegate that invokes all event handlers. Returns null if no handlers are register. More...
 
- Properties inherited from KS.Reactor.ksIEvent
int Count [get]
 The number of registered event handlers. More...
 
- Properties inherited from KS.Reactor.ksEvent< ksEvent< T >, T >
int Count [get]
 The number of registered event handlers. More...
 
Execute [get]
 Gets a delegate that invokes all event handlers. Returns null if no handlers are register. More...
 

Detailed Description

Wraps a C# event for the delegate T to allow event references.

Template Parameters
TDelegate type
Template Parameters
EThe type of this instance.
TDelegate type
Type Constraints
E :ksEvent 
E :E 
E :T 
T :class 

Member Function Documentation

◆ Add()

virtual void KS.Reactor.ksEvent< E, T >.Add ( item)
virtual

Adds an item to the event list.

Parameters
itemItem to add

Reimplemented from KS.Reactor.ksEvent< ksEvent< T >, T >.

Reimplemented in KS.Reactor.Server.ksUpdateEvent< T >, and KS.Reactor.ksEvent< E, T >.

◆ ForEach() [1/2]

virtual void KS.Reactor.ksEvent< E, T >.ForEach ( ForEachCallback  callback)
virtual

Iterate and invoke the callback on all items.

Parameters
callback

Reimplemented from KS.Reactor.ksEvent< ksEvent< T >, T >.

Reimplemented in KS.Reactor.Server.ksUpdateEvent< T >, and KS.Reactor.ksEvent< E, T >.

◆ ForEach() [2/2]

virtual bool KS.Reactor.ksEvent< E, T >.ForEach ( ForEachCancellableCallback  callback)
virtual

Iterate and invoke the callback on all items.

Parameters
callbackCallback to call on the items. Iteration will stop if it returns false.
Returns
False if iteration was cancelled because the callback returned false.

Reimplemented from KS.Reactor.ksEvent< ksEvent< T >, T >.

Reimplemented in KS.Reactor.ksEvent< E, T >.

◆ ForEachCallback()

delegate void KS.Reactor.ksEvent< E, T >.ForEachCallback ( item)

Iterator callback used with ForEach(ForEachCallback)

Parameters
item

◆ ForEachCancellableCallback()

delegate bool KS.Reactor.ksEvent< E, T >.ForEachCancellableCallback ( item)

Iterator callback that can cancel iteration by returning false.

Parameters
item
Returns
False to cancel iteration.

◆ operator+()

static E KS.Reactor.ksEvent< E, T >.operator+ ( ksEvent< E, T >  lhs,
rhs 
)
static

Adds an event handler to the event.

Parameters
lhsEvent to add handler to.
rhsHandler to add.
Returns
lhs

◆ operator-()

static E KS.Reactor.ksEvent< E, T >.operator- ( ksEvent< E, T >  lhs,
rhs 
)
static

Adds an event handler to the event.

Parameters
lhsEvent to add handler to.
rhsHandler to add.
Returns
lhs

◆ Remove()

virtual void KS.Reactor.ksEvent< E, T >.Remove ( item)
virtual

Remove an item from the event list.

Parameters
itemItem to be removed

Reimplemented from KS.Reactor.ksEvent< ksEvent< T >, T >.

Reimplemented in KS.Reactor.Server.ksUpdateEvent< T >, and KS.Reactor.ksEvent< E, T >.

Property Documentation

◆ Count

int KS.Reactor.ksEvent< E, T >.Count
get

The number of registered event handlers.

◆ Execute

T KS.Reactor.ksEvent< E, T >.Execute
get

Gets a delegate that invokes all event handlers. Returns null if no handlers are register.