Exemple #1
0
        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);
                    }
                }
            }
        }
Exemple #2
0
        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;
        }
Exemple #3
0
 public void BindValue(PropertyModel propertyModel)
 {
     ValueBind = new FieldBind <T>(propertyModel);
 }
Exemple #4
0
        protected virtual void SetupField(IFieldElement field, PropertyModel property)
        {
            field.BindValue(property);

            //TODO
        }