Пример #1
0
        public static string GetPluralName(this Type type)
        {
            PropertyDefinitionAttribute def = type.GetPropertyDefinition();

            if (def == null)
            {
                return(null);
            }

            return(def.PluralName);
        }
Пример #2
0
        private PropertyFactory()
        {
            this.PropertyTypes = new Dictionary <ushort, PropertyLookup>();
            foreach (Type type in Assembly.GetAssembly(this.GetType()).GetTypes())
            {
                if (type.IsSubclassOf(typeof(Property)))
                {
                    object[] attributes = type.GetCustomAttributes(typeof(PropertyDefinitionAttribute), false);
                    if (attributes.Length > 0)
                    {
                        PropertyDefinitionAttribute propDef = (PropertyDefinitionAttribute)(attributes[0]);

                        if (this.PropertyTypes.ContainsKey(propDef.FileType) == true)
                        {
                            throw new Exception("duplicate property type id " + propDef.FileType.ToString());
                        }

                        this.PropertyTypes[propDef.FileType]            = new PropertyLookup();
                        this.PropertyTypes[propDef.FileType].Type       = type;
                        this.PropertyTypes[propDef.FileType].Definition = propDef;
                    }
                }
            }
        }