Automation/Commands/Commands.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Text.RegularExpressions;


namespace ComLib.Automation
{
    /// <summary>
    /// Sample automation script command class.
    /// </summary>
    [Command(Name = "List", Description = "Lists all the automation commands available in the system")]
    public class CommandListCommands : Command
    {

        /// <summary>
        /// Get list of all the commands in the system.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override BoolMessageItem DoExecute(CommandContext context)
        {
            var filter = Get<string>("filter");
            string commandList = "";

            // No filter ? get all 
            if (string.IsNullOrEmpty(filter))
            {
                commandList = this.Script.Service.GetList(null, null);
                return new BoolMessageItem(commandList, true, string.Empty);
            }

            // Find by filter.
            commandList = this.Script.Service.GetList(null, (attrib) => attrib.Name.Contains(filter));
            return new BoolMessageItem(commandList, true, string.Empty);
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。