IsDefined() public static method

public static IsDefined ( Assembly element, Type attributeType ) : bool
element Assembly
attributeType Type
return bool
Esempio n. 1
0
        private static void ExtractOptions(EntityBase ent, IDictionary <string, List <DisplayOption> > dict)
        {
            var props = ent.GetType().GetPropertiesSorted();

            foreach (var info in props.Reverse())
            {
                //info
                if (!Attribute.IsDefined(info, typeof(EntityDescriptorAttribute)))
                {
                    continue;
                }
                var prop = (EntityDescriptorAttribute)info.GetCustomAttribute(typeof(EntityDescriptorAttribute));
                if (!dict.ContainsKey(prop.Category))
                {
                    dict.Add(prop.Category, new List <DisplayOption>());
                }

                object min = null, max = null;
                var    multiline = Attribute.IsDefined(info, typeof(MultilineStringAttribute));

                if (Attribute.IsDefined(info, typeof(MinMaxAttribute)))
                {
                    var att = (MinMaxAttribute)info.GetCustomAttribute(typeof(MinMaxAttribute));
                    min = att.Minimum;
                    max = att.Maximum;
                }

                dict[prop.Category].Insert(0,
                                           new DisplayOption(prop.Name, info.Name, info.PropertyType, ent, prop.Description, min, max, multiline, prop.IsEnabledPath, prop.FixedSize, prop.DataGridRowHeaderPath));
            }
        }