Exemplo n.º 1
0
        /// <summary>
        /// 注册以字面量打头的指令
        /// </summary>
        /// <param name="head">指令头</param>
        /// <returns>注册的第一个节点</returns>
        public CommandNode <TEnv> Register(string head)
        {
            CommandNode <TEnv> n = PresetNodes.Literal <TEnv>(head);

            Root.AddChild(n);
            return(n);
        }
Exemplo n.º 2
0
        /**
         * Utility method for registering new commands.
         *
         * <p>This is a shortcut for calling {@link RootCommandNode#addChild(CommandNode)} after building the provided {@code command}.</p>
         *
         * <p>As {@link RootCommandNode} can only hold literals, this method will only allow literal arguments.</p>
         *
         * @param command a literal argument builder to add to this command tree
         * @return the node added to this tree
         */
        public LiteralCommandNode <TSource> Register(LiteralArgumentBuilder <TSource> command)
        {
            var build = command.Build();

            _root.AddChild(build);
            return(build);
        }
Exemplo n.º 3
0
 public TThis Then <TChildNode>(IArgumentBuilder <TSource, TChildNode> argument) where TChildNode : CommandNode <TSource>
 {
     if (RedirectTarget != null)
     {
         throw new InvalidOperationException("Cannot add children to a redirected node");
     }
     _arguments.AddChild(argument.Build());
     return(This);
 }