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); } }
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); }
public CommandInfo() { Options = new CommandOptionsAttribute(); Rights = new HashSet <string>(); CommandNames = new HashSet <string>(); }