public static List <DesignerActionItem> GetAllAttributedActionItems(this DesignerActionList actionList) { var fullAIList = new List <DesignerActionItem>(); foreach (var mbr in actionList.GetType().GetMethods(allInstBind)) { foreach (IActionGetItem attr in mbr.GetCustomAttributes(typeof(DesignerActionMethodAttribute), false)) { if (mbr.ReturnType == typeof(void) && mbr.GetParameters().Length == 0) { fullAIList.Add(attr.GetItem(actionList, mbr)); } else { throw new FormatException("DesignerActionMethodAttribute must be applied to a method returning void and having no parameters."); } } } foreach (var mbr in actionList.GetType().GetProperties(allInstBind)) { foreach (IActionGetItem attr in mbr.GetCustomAttributes(typeof(DesignerActionPropertyAttribute), false)) { fullAIList.Add(attr.GetItem(actionList, mbr)); } } fullAIList.Sort(CompareItems); return(fullAIList); }
private static bool CheckCondition(DesignerActionList actionList, DesignerActionItem ai) { if (ai.Properties["Condition"] != null) { var p = actionList.GetType().GetProperty((string)ai.Properties["Condition"], allInstBind, null, typeof(bool), Type.EmptyTypes, null); if (p != null) { return((bool)p.GetValue(actionList, null)); } } return(true); }
public virtual void Invoke() { if (_methodInfo == null) { _methodInfo = _actionList?.GetType()?.GetMethod(MemberName, BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_methodInfo == null) { throw new InvalidOperationException(string.Format(SR.DesignerActionPanel_CouldNotFindMethod, MemberName)); } _methodInfo.Invoke(_actionList, null); }
private LineInfo ProcessTaskItem(DesignerActionList list, DesignerActionItem item) { Line line = null; if (item is DesignerActionMethodItem) { line = new MethodLine(this._serviceProvider, this); } else if (item is DesignerActionPropertyItem) { DesignerActionPropertyItem item2 = (DesignerActionPropertyItem) item; PropertyDescriptor propDesc = TypeDescriptor.GetProperties(list)[item2.MemberName]; if (propDesc == null) { throw new InvalidOperationException(System.Design.SR.GetString("DesignerActionPanel_CouldNotFindProperty", new object[] { item2.MemberName, list.GetType().FullName })); } TypeDescriptorContext context = new TypeDescriptorContext(this._serviceProvider, propDesc, list); UITypeEditor editor = (UITypeEditor) propDesc.GetEditor(typeof(UITypeEditor)); bool standardValuesSupported = propDesc.Converter.GetStandardValuesSupported(context); if (editor == null) { if (propDesc.PropertyType == typeof(bool)) { if (IsReadOnlyProperty(propDesc)) { line = new TextBoxPropertyLine(this._serviceProvider, this); } else { line = new CheckBoxPropertyLine(this._serviceProvider, this); } } else if (standardValuesSupported) { line = new EditorPropertyLine(this._serviceProvider, this); } else { line = new TextBoxPropertyLine(this._serviceProvider, this); } } else { line = new EditorPropertyLine(this._serviceProvider, this); } } else { if (!(item is DesignerActionTextItem)) { return null; } if (item is DesignerActionHeaderItem) { line = new HeaderLine(this._serviceProvider, this); } else { line = new TextLine(this._serviceProvider, this); } } return new LineInfo(list, item, line); }