private EventActivityBinder <TInstance, TData> GetBinder( Func <EventActivityBinder <TInstance, TData>, EventActivityBinder <TInstance, TData> > activityCallback) { EventActivityBinder <TInstance, TData> binder = new DataEventActivityBinder <TInstance, TData>(_machine, _event); return(activityCallback(binder)); }
ActivityBinder <TInstance> CreateConditionalActivityBinder() { EventActivityBinder <TInstance, TData> binder = new DataEventActivityBinder <TInstance, TData>(_machine, _event, _activities); var conditionBinder = new ConditionalActivityBinder <TInstance, TData>(_event, context => _filter(context), binder); return(conditionBinder); }
EventActivityBinder <TInstance, TData> EventActivityBinder <TInstance, TData> .If(StateMachineCondition <TInstance, TData> condition, Func <EventActivityBinder <TInstance, TData>, EventActivityBinder <TInstance, TData> > activityCallback) { EventActivityBinder <TInstance, TData> binder = new DataEventActivityBinder <TInstance, TData>(_machine, _event); binder = activityCallback(binder); var conditionBinder = new ConditionalActivityBinder <TInstance, TData>(_event, condition, binder); return(new DataEventActivityBinder <TInstance, TData>(_machine, _event, _filter, _activities, conditionBinder)); }
public ExceptionActivityBinder <TInstance> Handle <TException>( Func <EventActivityBinder <TInstance, TException>, EventActivityBinder <TInstance, TException> > context) where TException : Exception { EventActivityBinder <TInstance, TException> contextBinder = new DataEventActivityBinder <TInstance, TException>( _machine, new DataEvent <TException>(typeof(TException).Name)); contextBinder = context(contextBinder); var handler = new ExceptionHandlerActivity <TInstance, TException>(contextBinder, typeof(TException), contextBinder.Event); return(new ExceptionActivityBinderImpl <TInstance>(_machine, _event, _activities.Concat(Enumerable.Repeat(handler, 1)))); }