示例#1
0
 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());
         }
     }
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }