Example #1
0
 internal static void SetUniqueProperties(MemberInfo memberInfo, Action<UniqueAttribute> makeUnique)
 {
     var uniqueAttribute = memberInfo.TryGetAttribute<UniqueAttribute>();
     if (uniqueAttribute == null)
         return;
     makeUnique(uniqueAttribute);
 }
Example #2
0
        bool TryGetProperty(MemberInfo memberInfo, out EntityProperty property)
        {
            EditorPropertyAttribute propertyAttribute;
            if (memberInfo.TryGetAttribute(out propertyAttribute))
            {
                Type memberType = null;
                switch (memberInfo.MemberType)
                {
                    case MemberTypes.Field:
                        memberType = (memberInfo as FieldInfo).FieldType;
                        break;
                    case MemberTypes.Property:
                        memberType = (memberInfo as PropertyInfo).PropertyType;
                        break;
                }

                var limits = new EntityPropertyLimits(propertyAttribute.Min, propertyAttribute.Max);

                property = new EntityProperty(memberInfo.Name, propertyAttribute.Description, Entity.GetEditorType(memberType, propertyAttribute.Type), limits, propertyAttribute.Flags);
                return true;
            }

            property = new EntityProperty();
            return false;
        }
Example #3
0
        bool TryGetEntityProperty(MemberInfo memberInfo, ref Dictionary<string, List<EditorProperty>> folders)
        {
            EditorPropertyAttribute propertyAttribute;
            if (memberInfo.TryGetAttribute(out propertyAttribute))
            {
                Type memberType = null;
                switch (memberInfo.MemberType)
                {
                    case MemberTypes.Field:
                        memberType = (memberInfo as FieldInfo).FieldType;
                        break;
                    case MemberTypes.Property:
                        memberType = (memberInfo as PropertyInfo).PropertyType;
                        break;
                }

                var limits = new EditorPropertyLimits(propertyAttribute.Min, propertyAttribute.Max);

                var property = new EditorProperty(propertyAttribute.Name ?? memberInfo.Name, propertyAttribute.Description, Entity.GetEditorType(memberType, propertyAttribute.Type), limits, propertyAttribute.Flags);

                if (propertyAttribute.Folder == null)
                    propertyAttribute.Folder = "Default";

                if (!folders.ContainsKey(propertyAttribute.Folder))
                    folders.Add(propertyAttribute.Folder, new List<EditorProperty>());

                folders[propertyAttribute.Folder].Add(property);

                return true;
            }

            return false;
        }