コード例 #1
0
        /// <summary>
        /// Return whether the given command has an attribute which marks the commands as a wrapper command (= wheter it calls other commands)
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        private bool IsWrapperCommand(Command cmd)
        {
            Attribute[]        attrs = Attribute.GetCustomAttributes(cmd.GetType());
            CommandDescription descr = (CommandDescription)attrs.FirstOrDefault(a => a is CommandDescription);

            return(descr != null ? descr.Wrapper : false);
        }
コード例 #2
0
        /// <summary>
        /// Return the command description that is part of the class definition
        /// </summary>
        /// <returns></returns>
        public string GetCommandDescription()
        {
            Attribute attr = Attribute.GetCustomAttributes(GetType()).FirstOrDefault(a => a is CommandDescription);

            if (attr != null)
            {
                CommandDescription descr = (CommandDescription)attr;
                return(descr.Description);
            }
            else
            {
                return("No command description available");
            }
        }
コード例 #3
0
        protected override void DoCommandAction()
        {
            foreach (Type type in CommandStringParser.GetAllCommandTypes().OrderBy(t => t.Name))
            {
                // create instance to get default value
                Command cmd = (Command)Activator.CreateInstance(type);

                bool commandDescriptionFound = false;
                foreach (Attribute attr in Attribute.GetCustomAttributes(type).Where(a => a is CommandDescription))
                {
                    CommandDescription descr = (CommandDescription)attr;
                    if (!string.IsNullOrEmpty(descr.Description))
                    {
                        commandDescriptionFound = true;
                        break;
                    }
                }
                if (!commandDescriptionFound)

                {
                    OutputManager.WriteOutput(type.Name + " has no Command Description");
                }
            }
        }