Ejemplo n.º 1
0
        public override LiteralCommandNode <TSource> Build()
        {
            var result = new LiteralCommandNode <TSource>(Literal, Command, Requirement, RedirectTarget, RedirectModifier, IsFork);

            foreach (var argument in Arguments)
            {
                result.AddChild(argument);
            }

            return(result);
        }
Ejemplo n.º 2
0
    public void setup()
    {
        subject = new CommandDispatcher <object>();
        subject.Register(r =>
                         r.Literal("a")
                         .Then(
                             r.Literal("1")
                             .Then(r.Literal("i").Executes(c => 0))
                             .Then(r.Literal("ii").Executes(c => 0))
                             )
                         .Then(
                             r.Literal("2")
                             .Then(r.Literal("i").Executes(c => 0))
                             .Then(r.Literal("ii").Executes(c => 0))
                             )
                         );
        subject.Register(r => r.Literal("b").Then(r.Literal("1").Executes(c => 0)));
        subject.Register(r => r.Literal("c").Executes(c => 0));
        subject.Register(r => r.Literal("d").Requires(s => false).Executes(c => 0));
        subject.Register(r =>
                         r.Literal("e")
                         .Executes(c => 0)
                         .Then(
                             r.Literal("1")
                             .Executes(c => 0)
                             .Then(r.Literal("i").Executes(c => 0))
                             .Then(r.Literal("ii").Executes(c => 0))
                             )
                         );
        subject.Register(r =>
                         r.Literal("f")
                         .Then(
                             r.Literal("1")
                             .Then(r.Literal("i").Executes(c => 0))
                             .Then(r.Literal("ii").Executes(c => 0).Requires(s => false))
                             )
                         .Then(
                             r.Literal("2")
                             .Then(r.Literal("i").Executes(c => 0).Requires(s => false))
                             .Then(r.Literal("ii").Executes(c => 0))
                             )
                         );
        subject.Register(r =>
                         r.Literal("g")
                         .Executes(c => 0)
                         .Then(r.Literal("1").Then(r.Literal("i").Executes(c => 0)))
                         );
        LiteralCommandNode <Object> h = subject.Register(r =>
                                                         r.Literal("h")
                                                         .Executes(c => 0)
                                                         .Then(r.Literal("1").Then(r.Literal("i").Executes(c => 0)))
                                                         .Then(r.Literal("2").Then(r.Literal("i").Then(r.Literal("ii").Executes(c => 0))))
                                                         .Then(r.Literal("3").Executes(c => 0))
                                                         );

        subject.Register(r =>
                         r.Literal("i")
                         .Executes(c => 0)
                         .Then(r.Literal("1").Executes(c => 0))
                         .Then(r.Literal("2").Executes(c => 0))
                         );
        subject.Register(r =>
                         r.Literal("j")
                         .Redirect(subject.GetRoot())
                         );
        subject.Register(r =>
                         r.Literal("k")
                         .Redirect(h)
                         );
    }
Ejemplo n.º 3
0
        public LiteralCommandNodeTest()
        {
            _node = LiteralArgumentBuilder <object> .LiteralArgument("foo").Build();

            _contextBuilder = new CommandContextBuilder <object>(new CommandDispatcher <object>(), new object(), new RootCommandNode <object>(), 0);
        }