protected virtual IEnumerable <IFieldElement> GetFields(PropertyModel property) { var attributes = property.Attributes.Select(s => s.Attribute).OfType <IFieldAttribute>().ToArray(); if (!attributes.Any()) { foreach (var field in GetDefaultFieldForType(property)) { yield return(field); } } else { foreach (var attribute in attributes) { foreach (var field in attribute.GetFields()) { yield return(field); } } } }
protected virtual IEnumerable <IFieldElement> GetDefaultFieldForType(PropertyModel property) { var propertyInfo = property.PropertyInfo; if (propertyInfo.Name == "Id") { yield return(new PrimaryKeyField()); } else if (propertyInfo.PropertyType == typeof(string)) { yield return(new TextField()); } else if (propertyInfo.PropertyType == typeof(int)) { yield return(new IntegerField()); } else if (propertyInfo.PropertyType == typeof(int?)) { yield return(new NullableIntegerField()); } else if (propertyInfo.PropertyType == typeof(double)) { yield return(new DoubleField()); } else if (propertyInfo.PropertyType == typeof(double?)) { yield return(new NullableDoubleField()); } else if (propertyInfo.PropertyType == typeof(float)) { yield return(new FloatField()); } else if (propertyInfo.PropertyType == typeof(float?)) { yield return(new NullableFloatField()); } else if (propertyInfo.PropertyType == typeof(decimal)) { yield return(new DecimalField()); } else if (propertyInfo.PropertyType == typeof(decimal?)) { yield return(new NullableDecimalField()); } else if (propertyInfo.PropertyType == typeof(DateTime)) { yield return(new DateField()); } else if (propertyInfo.PropertyType == typeof(DateTime?)) { yield return(new NullableDateField()); } else if (propertyInfo.PropertyType == typeof(bool)) { yield return(new BooleanField()); } else if (propertyInfo.PropertyType == typeof(bool?)) { yield return(new NullableBooleanField()); } yield break; }
public void BindValue(PropertyModel propertyModel) { ValueBind = new FieldBind <T>(propertyModel); }
protected virtual void SetupField(IFieldElement field, PropertyModel property) { field.BindValue(property); //TODO }