/// <summary> /// Only intended to be used by the EntityFramework itself! Creates the native property information for a reflected managed property and returns the created managed EntityProperty. Returns 'null', if the property is not marked as 'EntityProperty', or no property converter can be found for the type of the property. /// </summary> /// <param name="managed">Managed.</param> internal static EntityProperty Create(PropertyInfo managed) { EntityPropertyAttribute attrib = (EntityPropertyAttribute)managed.GetCustomAttributes(typeof(EntityPropertyAttribute), true).FirstOrDefault(); if (attrib == null) { return(null); } if (!s_converters.ContainsKey(managed.PropertyType)) { return(null); } EEditTypes editType = attrib.EditType; if (editType == EEditTypes.Default) { editType = s_converters [managed.PropertyType].DefaultEditType; } string strEditType = StringValueAttribute.GetStringValue(editType); IEntityPropertyHandler.SPropertyInfo engine = new IEntityPropertyHandler.SPropertyInfo(); engine.name = managed.Name; engine.description = attrib.Description; engine.editType = strEditType; engine.limits = new IEntityPropertyHandler.SPropertyInfo.SLimits(); engine.limits.min = attrib.Min; engine.limits.max = attrib.Max; engine.type = s_converters [managed.PropertyType].EngineType; return(new EntityProperty(managed, engine, attrib.Default)); }
public EntityPropertyAttribute(string description = null, EEditTypes editType = EEditTypes.Default, float min = Int16.MinValue, float max = Int16.MaxValue, string defaultValue = null) { Description = description; EditType = editType; Min = min; Max = max; Default = defaultValue; }