public static void DefineGivenCommand(IStageCommandConfig <Visitor> stageConfig, string commandName, string commandDefinition)
                {
                    switch (commandDefinition)
                    {
                    case BasicCommand:
                        stageConfig.WithCommand <Visitor, BasicCommand>(commandName,
                                                                        (s, arg) => s.Visit($"{arg.CommandName}:{arg.Payload}"),
                                                                        (s, arg) => s.PostVisit($"{arg.CommandName}:{arg.Payload}"));
                        break;

                    case DerivedCommand:
                        stageConfig.WithCommand <Visitor, DerivedCommand>(commandName,
                                                                          (s, arg) => s.Visit($"{arg.CommandName}:{arg.Payload}"),
                                                                          (s, arg) => s.PostVisit($"{arg.CommandName}:{arg.Payload}"));
                        break;

                    case DerivedCommandV2:
                        stageConfig.WithCommand <Visitor, DerivedCommandV2>(commandName,
                                                                            (s, arg) => s.Visit($"{arg.CommandName}:{arg.Payload}"),
                                                                            (s, arg) => s.PostVisit($"{arg.CommandName}:{arg.Payload}"));
                        break;

                    case UnrelatedCommand:
                        stageConfig.WithCommand <Visitor, UnrelatedCommand>(commandName,
                                                                            (s, arg) => s.Visit($"{arg.CommandName}:{arg.Payload}"),
                                                                            (s, arg) => s.PostVisit($"{arg.CommandName}:{arg.Payload}"));
                        break;

                    default:
                        throw new NotImplementedException(commandDefinition);
                    }
                }
Example #2
0
 public static IStageCommandConfig <TStage> WithCommand <TStage, TPayload>(this IStageCommandConfig <TStage> stageConfig, string commandName,
                                                                           Action <TStage, ICommandParams <TPayload> > command,
                                                                           Action <TStage, ICommandParams <TPayload> > postCommand = null)
 {
     stageConfig.DefineCommand(commandName, new CommandDefinition <TStage, TPayload>(command, postCommand));
     return(stageConfig);
 }
Example #3
0
        public static IStageCommandConfig <Visitor> WithSessionCommands(this IStageCommandConfig <Visitor> commandConfig)
        {
            commandConfig
            .WithStartSessionCommand(s => s.StartSession(), s => s.PostStartSession())
            .WithAbortSessionCommand(s => s.AbortSession(), s => s.PostAbortSession())
            .WithEndSessionCommand(s => s.EndSession(), s => s.PostEndSession());

            return(commandConfig);
        }
Example #4
0
        public static IStageCommandConfig <Visitor> WithVisitCommand(this IStageCommandConfig <Visitor> commandConfig, string commandName, PipelineAction actionAfterVisit = PipelineAction.Continue, PipelineAction actionAfterPostVisit = PipelineAction.Continue)
        {
            var stringCommand = new CommandDefinition <Visitor, string>(
                (s, arg) => { s.Visit(arg.Payload); return(actionAfterVisit); },
                (s, arg) => { s.PostVisit(arg.Payload); return(actionAfterPostVisit); });

            commandConfig
            .WithCommand(commandName, stringCommand);

            return(commandConfig);
        }
Example #5
0
 public static IStageCommandConfig <TStage> WithEndSessionCommand <TStage>(this IStageCommandConfig <TStage> stageConfig, ISessionCommandDefinition <TStage> sessionCommand)
 {
     stageConfig.DefineEndSessionCommand(sessionCommand);
     return(stageConfig);
 }
Example #6
0
 public static IStageCommandConfig <TStage> WithEndSessionCommand <TStage>(this IStageCommandConfig <TStage> stageConfig, Action <TStage> sessionCommand, Action <TStage> postSessionCommand = null)
 {
     stageConfig.DefineEndSessionCommand(new SessionCommandDefinition <TStage>(sessionCommand, postSessionCommand));
     return(stageConfig);
 }
Example #7
0
 public static IStageCommandConfig <TStage> WithCommand <TStage, TPayload>(this IStageCommandConfig <TStage> stageConfig, string commandName,
                                                                           ICommandDefinition <TStage, TPayload> commandDefinition)
 {
     stageConfig.DefineCommand(commandName, commandDefinition);
     return(stageConfig);
 }
Example #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name">Name of Stage - must be unique within the context of a configured pipeline. If null, will use <code>typeof(TStage).FullName</code></param>
 /// <param name="stageFactory"></param>
 /// <param name="commandConfig"></param>
 public StageConfig(string name, Func <TStage> stageFactory, IStageCommandConfig <TStage> commandConfig = null)
 {
     Name          = string.IsNullOrWhiteSpace(name) ? typeof(TStage).FullName : name;
     _stageFactory = stageFactory;
     CommandConfig = commandConfig ?? new StageCommandConfig <TStage>();
 }