예제 #1
0
        public CommandInfo(ICustomAttributeProvider fieldInfo)
        {
            if (fieldInfo == null)
            {
                throw new ArgumentNullException("fieldInfo");
            }

            Options = new CommandOptionsAttribute();

            foreach (CommandOptionsAttribute optionsAttribute in fieldInfo.GetCustomAttributes(typeof(CommandOptionsAttribute), false))
            {
                Options = optionsAttribute.Clone();
                break;
            }

            CommandNames = new HashSet <string>();

            foreach (CommandNameAttribute nameAttribute in fieldInfo.GetCustomAttributes(typeof(CommandNameAttribute), false))
            {
                CommandNames.UnionWith(nameAttribute.CommandNames);
            }

            Rights = new HashSet <string>();

            foreach (CommandRightAttribute rightAttribute in fieldInfo.GetCustomAttributes(typeof(CommandRightAttribute), false))
            {
                Rights.UnionWith(rightAttribute.CommandRights);
            }
        }
예제 #2
0
        public static CommandOptionsAttribute GetCommandOptions(this Command command)
        {
            FieldInfo fieldInfo = typeof(Command).GetField(command.ToString(), BindingFlags.Static | BindingFlags.Public);

            CommandOptionsAttribute result = new CommandOptionsAttribute();

            foreach (CommandOptionsAttribute optionsAttribute in fieldInfo.GetCustomAttributes(typeof(CommandOptionsAttribute), false))
            {
                result = optionsAttribute.Clone();
                break;
            }

            return(result);
        }
예제 #3
0
 public CommandInfo()
 {
     Options      = new CommandOptionsAttribute();
     Rights       = new HashSet <string>();
     CommandNames = new HashSet <string>();
 }