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);
                    }
                }
Exemplo n.º 2
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);
        }