Class ConditionalEventBase<TEvent, TArgs>
Defines a conditional event
public abstract class ConditionalEventBase<TEvent, TArgs> : IConditionalEvent<TEvent> where TEvent : ConditionalEventBase<TEvent, TArgs> where TArgs : EventArgs
Type Parameters
TEvent
TArgs
- Inheritance
-
objectConditionalEventBase<TEvent, TArgs>
- Implements
-
IConditionalEvent<TEvent>
- Derived
- Extension Methods
Constructors
ConditionalEventBase()
Constructor
protected ConditionalEventBase()
Properties
Conditions
Condition for the handler execution. If set, must return true in order to execute the handler
protected List<ConditionalEventBase<TEvent, TArgs>.ConditionFunction> Conditions { get; set; }
Property Value
- List<ConditionalEventBase<TEvent, TArgs>.ConditionFunction>
Handler
Handler to execute
protected EventHandler<TArgs> Handler { get; set; }
Property Value
- EventHandler<TArgs>
Repeats
Number of repeats of the action
protected int Repeats { get; set; }
Property Value
- int
TypedThis
Strongly typed identity
protected TEvent TypedThis { get; }
Property Value
- TEvent
Methods
Call(Action)
Calls the given handler
public TEvent Call(Action handler)
Parameters
handler
ActionHandler to call
Returns
- TEvent
Call(Action<TArgs>)
Calls the given handler
public TEvent Call(Action<TArgs> handler)
Parameters
handler
Action<TArgs>Handler to call
Returns
- TEvent
Call(EventHandler<TArgs>)
Calls the given handler
public TEvent Call(EventHandler<TArgs> handler)
Parameters
handler
EventHandler<TArgs>Handler to call
Returns
- TEvent
ExecuteHandler(object, TArgs)
Executes the handler
protected virtual void ExecuteHandler(object sender, TArgs args)
Parameters
sender
objectSender
args
TArgsEvent arguments
GetHandler()
Implicit operator to convert to event handler
public EventHandler<TArgs> GetHandler()
Returns
- EventHandler<TArgs>
Repeat(int)
Sets the number of allowed calls to the event
public TEvent Repeat(int i)
Parameters
i
intNumber of allowed calls
Returns
- TEvent
When(ConditionFunction)
Adds the condition to the conditional event
public TEvent When(ConditionalEventBase<TEvent, TArgs>.ConditionFunction condition)
Parameters
condition
ConditionalEventBase<TEvent, TArgs>.ConditionFunction
Returns
- TEvent
When(Func<bool>)
Adds the condition to the conditional event
public TEvent When(Func<bool> condition)
Parameters
condition
Func<bool>
Returns
- TEvent
When(Func<TArgs, bool>)
Adds the condition to the conditional event
public TEvent When(Func<TArgs, bool> condition)
Parameters
condition
Func<TArgs, bool>
Returns
- TEvent
Operators
implicit operator EventHandler<TArgs>(ConditionalEventBase<TEvent, TArgs>)
Implicit operator to convert to event handler
public static implicit operator EventHandler<TArgs>(ConditionalEventBase<TEvent, TArgs> ev)
Parameters
ev
ConditionalEventBase<TEvent, TArgs>
Returns
- EventHandler<TArgs>