public static void RedirectRegisteredProperties(this ComponentDesigner d, IDictionary properties, IDictionary <string, List <Attribute> > redirectedProps) { foreach (var propName in redirectedProps.Keys) { var oldPropertyDescriptor = (PropertyDescriptor)properties[propName]; if (oldPropertyDescriptor != null) { var attributes = redirectedProps[propName]; properties[propName] = TypeDescriptor.CreateProperty(d.GetType(), oldPropertyDescriptor, attributes.ToArray()); } } }
public static DesignerVerbCollection GetAttributedVerbs(this ComponentDesigner designer) { var verbs = new DesignerVerbCollection(); foreach (var m in designer.GetType().GetMethods(allInstBind)) { foreach (DesignerVerbAttribute attr in m.GetCustomAttributes(typeof(DesignerVerbAttribute), true)) { verbs.Add(attr.GetDesignerVerb(designer, m)); } } return(verbs.Count > 0 ? verbs : null); }
public static IDictionary <string, List <Attribute> > GetRedirectedProperties(this ComponentDesigner d) { var ret = new Dictionary <string, List <Attribute> >(); foreach (var prop in d.GetType().GetProperties(allInstBind)) { foreach (RedirectedDesignerPropertyAttribute attr in prop.GetCustomAttributes(typeof(RedirectedDesignerPropertyAttribute), false)) { List <Attribute> attributes; if (attr.ApplyOtherAttributes) { attributes = prop.GetCustomAttributes <Attribute>().ToList(); attributes.RemoveAll(a => a is RedirectedDesignerPropertyAttribute); } else { attributes = new List <Attribute>(); } ret.Add(prop.Name, attributes); } } return(ret.Count > 0 ? ret : null); }