public ArrayList GetCommandsByType(Type classType, IToolBarCommandHandler commandHandler) { string Topic = ""; object[] topictype = classType.GetCustomAttributes(typeof(TopicTypeAttribute), false); foreach (object o in topictype) { if (o is TopicTypeAttribute) { Topic = ((TopicTypeAttribute)o).Name; } } ArrayList methods = new ArrayList(); MethodInfo[] mi = classType.GetMethods(); for (int x = 0; x < mi.Length; x++) { Object[] MethodAttrs = mi[x].GetCustomAttributes(typeof(ToolCommandAttribute), false); for (int n = 0; n < MethodAttrs.Length; n++) { if (MethodAttrs[n] is ToolCommandAttribute) { if (((ToolCommandAttribute)MethodAttrs[n]).TopicName == "") { ((ToolCommandAttribute)MethodAttrs[n]).TopicName = Topic; } methods.Add(new SomeCommand(mi[x], (ToolCommandAttribute)MethodAttrs[n], commandHandler)); } } } return(methods); }
public SomeCommand(MethodInfo m, ToolCommandAttribute t, IToolBarCommandHandler commandHandler) { mMethod = m; mSettings = t; mCommandHandler = commandHandler; }
public ArrayList GetCommandsFromObject(object obj, IToolBarCommandHandler commandHandler) { Type classType = obj.GetType(); return(GetCommandsByType(classType, commandHandler)); }