Esempio n. 1
0
        public override void MapField(
            ICustomizersHolder customizerHolder,
            IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder,
            PropertyPath currentPropertyPath,
            MetaEntity entity,
            MetaField field)
        {
            var primitiveProperty = (PrimitiveMetaField)field;
            var mappingAction     = new Action <IPropertyMapper>(mapper => {
                if (field.MaxLength != null && field.MaxLength > 0)
                {
                    mapper.Length(field.MaxLength.Value);
                }
                else
                {
                    mapper.Type(NHibernateUtil.StringClob);
                }
                mapper.Column(field.DbName);
                mapper.Unique(field.IsUnique);
                mapper.Lazy(field.IsLazy);
                mapper.NotNullable(primitiveProperty.IsRequired);
            });
            var next = new PropertyPath(currentPropertyPath, field.ClrPropertyInfo);

            customizerHolder.AddCustomizer(next, mappingAction);
            modelExplicitDeclarationsHolder.AddAsProperty(field.ClrPropertyInfo);
        }
Esempio n. 2
0
 public DynamicComponentCustomizer(
     IModelExplicitDeclarationsHolder explicitDeclarationsHolder,
     ICustomizersHolder customizersHolder,
     PropertyPath propertyPath)
     : this(typeof(TComponent), explicitDeclarationsHolder, customizersHolder, propertyPath)
 {
 }
Esempio n. 3
0
        private static void Groups(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <GroupsAttribute>();

            if (attribute != null)
            {
                var membersByGroup = customizerHolder.Type.GetProperties()
                                     .Where(x => x.GetCustomAttribute <DisplayAttribute>() != null)
                                     .GroupBy(x => x.GetCustomAttribute <DisplayAttribute>().GroupName)
                                     .ToDictionary(x => x.Key, x => x.ToList());
                foreach (var group in attribute.Groups)
                {
                    var trimmedGroup = group.TrimEnd('*');
                    var properties   = Enumerable.Empty <PropertyInfo>();
                    if (membersByGroup.ContainsKey(group))
                    {
                        properties = properties.Union(membersByGroup[group]);
                    }
                    if (membersByGroup.ContainsKey(trimmedGroup))
                    {
                        properties = properties.Union(membersByGroup[trimmedGroup]);
                    }
                    customizerHolder.PropertyGroup(trimmedGroup, group.EndsWith("*"), properties);
                }
            }
        }
Esempio n. 4
0
        private static void Template(
            MemberInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var uiHintAttribute   = attributes.GetAttribute <UIHintAttribute>();
            var templateAttribute = attributes.GetAttribute <TemplateAttribute>();

            if (uiHintAttribute != null || templateAttribute != null)
            {
                string editor = null, display = null;
                if (uiHintAttribute != null)
                {
                    editor = display = uiHintAttribute.UIHint;
                }
                if (templateAttribute != null)
                {
                    if (!templateAttribute.DisplayTemplate.IsNullOrEmpty())
                    {
                        display = templateAttribute.DisplayTemplate;
                    }
                    if (!templateAttribute.EditorTemplate.IsNullOrEmpty())
                    {
                        editor = templateAttribute.EditorTemplate;
                    }
                }

                customizerHolder.Property(member, x =>
                {
                    x.Template(display, editor);
                });
            }
        }
Esempio n. 5
0
        public override void MapField(ICustomizersHolder customizerHolder,
                                      IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder,
                                      PropertyPath currentPropertyPath,
                                      MetaEntity entity,
                                      MetaField property)
        {
            var o2mProperty = property as OneToManyMetaField;
            var refEntity   = _entityManager.GetEntity(o2mProperty.RefEntityName);
            var refProperty = refEntity.Fields[o2mProperty.MappedByFieldName];

            var bagMappingAction = new Action <IBagPropertiesMapper>(mapper => {
                mapper.Inverse(true);
                mapper.Key(keyMapper => {
                    keyMapper.Column(property.DbName);
                });
            });

            var o2mMappingAction = new Action <IOneToManyMapper>(mapper => {
                mapper.Class(refEntity.ClrType);
            });

            var next = new PropertyPath(currentPropertyPath, property.ClrPropertyInfo);

            customizerHolder.AddCustomizer(next, o2mMappingAction);
            customizerHolder.AddCustomizer(next, bagMappingAction);

            modelExplicitDeclarationsHolder.AddAsOneToManyRelation(property.ClrPropertyInfo);
            modelExplicitDeclarationsHolder.AddAsBag(property.ClrPropertyInfo);
        }
Esempio n. 6
0
        public override void MapField(ICustomizersHolder customizerHolder,
                                      IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder,
                                      PropertyPath currentPropertyPath,
                                      MetaEntity entity,
                                      MetaField property)
        {
            var m2mProperty = property as ManyToManyMetaField;
            var refEntity   = _entityManager.GetEntity(m2mProperty.RefEntityName);
            var refProperty = refEntity.Fields[m2mProperty.MappedByFieldName];
            var joinTableThisSideFkColumn  = _nameConvention.EntityFieldToColumn(entity.Name.Split('.').Last() + "Id");
            var joinTableOtherSideFkColumn = _nameConvention.EntityFieldToColumn(refEntity.Name.Split('.').Last() + "Id");

            var bagMappingAction = new Action <IBagPropertiesMapper>(mapper => {
                mapper.Table(m2mProperty.JoinTable);
                mapper.Key(keyMapper => {
                    keyMapper.Column(joinTableThisSideFkColumn);
                    keyMapper.NotNullable(true);
                });
            });

            var m2mMappingAction = new Action <IManyToManyMapper>(mapper => {
                mapper.Class(refEntity.ClrType);
                mapper.Column(joinTableOtherSideFkColumn);
            });

            var next = new PropertyPath(currentPropertyPath, property.ClrPropertyInfo);

            customizerHolder.AddCustomizer(next, m2mMappingAction);
            customizerHolder.AddCustomizer(next, bagMappingAction);

            modelExplicitDeclarationsHolder.AddAsManyToManyItemRelation(property.ClrPropertyInfo);
            modelExplicitDeclarationsHolder.AddAsBag(property.ClrPropertyInfo);
        }
Esempio n. 7
0
        public EntityCustomizer(ICustomizersHolder customizersHolder)
        {
            if (customizersHolder == null)
            {
                throw new ArgumentNullException(nameof(customizersHolder));
            }

            CustomizersHolder = customizersHolder;
        }
Esempio n. 8
0
 private ConventionModelMapper(string tablePrefix, IModelInspector modelInspector, ICustomizersHolder customizerHolder)
     : base(modelInspector, modelInspector as IModelExplicitDeclarationsHolder, customizerHolder, new DefaultCandidatePersistentMembersProvider())
 {
     Conventions = new MappingConventions
     {
         TablePrefix = tablePrefix
     };
     CustomizersHolder = customizerHolder;
     AppendDefaultEvents();
 }
 public PropertyContainerCustomizer(IModelExplicitDeclarationsHolder explicitDeclarationsHolder, ICustomizersHolder customizersHolder, PropertyPath propertyPath)
 {
     if (explicitDeclarationsHolder == null)
     {
         throw new ArgumentNullException("explicitDeclarationsHolder");
     }
     this.explicitDeclarationsHolder = explicitDeclarationsHolder;
     CustomizersHolder = customizersHolder;
     PropertyPath      = propertyPath;
 }
Esempio n. 10
0
 public MapKeyManyToManyCustomizer(IModelExplicitDeclarationsHolder explicitDeclarationsHolder, PropertyPath propertyPath, ICustomizersHolder customizersHolder)
 {
     if (explicitDeclarationsHolder == null)
     {
         throw new ArgumentNullException("explicitDeclarationsHolder");
     }
     explicitDeclarationsHolder.AddAsManyToManyKeyRelation(propertyPath.LocalMember);
     this.propertyPath      = propertyPath;
     this.customizersHolder = customizersHolder;
 }
Esempio n. 11
0
 public CollectionElementRelationCustomizer(IModelExplicitDeclarationsHolder explicitDeclarationsHolder, PropertyPath propertyPath, ICustomizersHolder customizersHolder)
 {
     if (explicitDeclarationsHolder == null)
     {
         throw new ArgumentNullException("explicitDeclarationsHolder");
     }
     this.explicitDeclarationsHolder = explicitDeclarationsHolder;
     this.propertyPath      = propertyPath;
     this.customizersHolder = customizersHolder;
 }
 private static void Table(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<TableAttribute>();
     if (attribute != null)
     {
         customizerHolder.Table(attribute.Name, attribute.Schema);
     }
 }
		public ManyToManyCustomizer(IModelExplicitDeclarationsHolder explicitDeclarationsHolder, PropertyPath propertyPath, ICustomizersHolder customizersHolder)
		{
			if (explicitDeclarationsHolder == null)
			{
				throw new ArgumentNullException("explicitDeclarationsHolder");
			}
			explicitDeclarationsHolder.AddAsManyToManyRelation(propertyPath.LocalMember);
			this.propertyPath = propertyPath;
			this.customizersHolder = customizersHolder;
		}
Esempio n. 14
0
        private static void Editable(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <EditableAttribute>();

            if (attribute != null)
            {
                customizerHolder.Editable(attribute.AllowEdit);
            }
        }
Esempio n. 15
0
        private static void Deletable(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <DeletableAttribute>();

            if (attribute != null)
            {
                customizerHolder.Deletable(attribute.AllowDelete);
            }
        }
Esempio n. 16
0
        private static void ConcurrencyCheck(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <EntityConcurrencyCheckAttribute>();

            if (attribute != null)
            {
                customizerHolder.ConcurrencyCheck();
            }
        }
 private static void Display(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<VerboseAttribute>();
     if (attribute != null)
     {
         customizerHolder.Display(attribute.Singular, attribute.Plural);
         customizerHolder.Group(attribute.GroupName);
     }
 }
Esempio n. 18
0
        private static void Table(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <TableAttribute>();

            if (attribute != null)
            {
                customizerHolder.Table(attribute.Name, attribute.Schema);
            }
        }
Esempio n. 19
0
        private static void SoftDelete(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <SoftDeleteAttribute>();

            if (attribute != null)
            {
                customizerHolder.SoftDelete();
            }
        }
Esempio n. 20
0
        private static void DisplayFormat(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <RecordDisplayAttribute>();

            if (attribute != null)
            {
                customizerHolder.DisplayFormat(attribute.DisplayFormat);
            }
        }
Esempio n. 21
0
        private static void Display(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <VerboseAttribute>();

            if (attribute != null)
            {
                customizerHolder.Display(attribute.Singular, attribute.Plural);
                customizerHolder.Group(attribute.GroupName);
            }
        }
 private static void SearchProperties(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<SearchAttribute>();
     if (attribute != null)
     {
         var members = customizerHolder.Type.GetProperties()
             .Where(x => attribute.Columns.Contains(x.Name));
         customizerHolder.SearchProperties(members);
     }
 }
Esempio n. 23
0
        private static void SearchProperties(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <SearchAttribute>();

            if (attribute != null)
            {
                var members = customizerHolder.Type.GetProperties()
                              .Where(x => attribute.Columns.Contains(x.Name));
                customizerHolder.SearchProperties(members);
            }
        }
Esempio n. 24
0
        private static void DataType(
            MemberInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var dataTypeAttribute = attributes.GetAttribute <DataTypeAttribute>();

            if (dataTypeAttribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Type(dataTypeAttribute.DataType);
                });
                return;
            }

            var enumDataTypeAttribute = attributes.GetAttribute <EnumDataTypeAttribute>();

            if (enumDataTypeAttribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Enum(enumDataTypeAttribute.EnumType);
                });
                return;
            }

            var imageAttribute = attributes.GetAttribute <ImageSettingsAttribute>();

            if (imageAttribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Type(Core.DataType.Image);
                });
                return;
            }

            var fileAttribute = attributes.GetAttribute <FileAttribute>();

            if (fileAttribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Type(fileAttribute.IsImage ?
                           Core.DataType.Image :
                           Core.DataType.File);
                });
                return;
            }
        }
Esempio n. 25
0
        private static void Links(
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <LinksAttribute>();

            if (attribute != null)
            {
                customizerHolder.Link(
                    attribute.DisplayLink,
                    attribute.EditLink,
                    attribute.DeleteLink);
            }
        }
Esempio n. 26
0
        private static void Required(
            MemberInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <RequiredAttribute>();

            if (attribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Required(attribute.ErrorMessage);
                });
            }
        }
Esempio n. 27
0
        private static void Column(
            MemberInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <ColumnAttribute>();

            if (attribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Column(attribute.Name);
                });
            }
        }
Esempio n. 28
0
        private static void Display(
            MemberInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <DisplayAttribute>();

            if (attribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Display(attribute.Name, attribute.Description);
                });
            }
        }
Esempio n. 29
0
        private static void DefaultFilter(
            PropertyInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <DefaultFilterAttribute>();

            if (attribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.DefaultFilter(attribute.Value);
                });
            }
        }
Esempio n. 30
0
        private static void ConcurrencyCheck(
            PropertyInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <PropertyConcurrencyCheckAttribute>();

            if (attribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.IsConcurrencyCheck();
                });
            }
        }
Esempio n. 31
0
        private static void Timestamp(
            PropertyInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <TimestampAttribute>();

            if (attribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.IsTimestamp();
                });
            }
        }
Esempio n. 32
0
        private static void Filterable(
            PropertyInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <FilterableAttribute>();

            if (attribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Filterable();
                });
            }
        }
Esempio n. 33
0
        private static void ForeignKey(
            MemberInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <ForeignKeyAttribute>();

            if (attribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.ForeignKey(attribute.Name);
                });
            }
        }
Esempio n. 34
0
        private static void Validation(
            PropertyInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var validators = attributes.GetAttributes <ValidationAttribute>();

            if (validators.IsNullOrEmpty() == false)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Validators(validators);
                });
            }
        }
Esempio n. 35
0
        private static void DisplayFormat(
            MemberInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var attribute = attributes.GetAttribute <DisplayFormatAttribute>();

            if (attribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Format(attribute.DataFormatString);
                });
            }
        }
Esempio n. 36
0
        internal static void Initialise(ICustomizersHolder customizerHolder)
        {
            var attributes = customizerHolder.Type.GetCustomAttributes(false);

            Table(customizerHolder, attributes);
            SearchProperties(customizerHolder, attributes);
            DisplayFormat(customizerHolder, attributes);
            Display(customizerHolder, attributes);
            Links(customizerHolder, attributes);
            Editable(customizerHolder, attributes);
            Deletable(customizerHolder, attributes);
            Columns(customizerHolder, attributes);
            Groups(customizerHolder, attributes);
            SoftDelete(customizerHolder, attributes);
            ConcurrencyCheck(customizerHolder, attributes);

            foreach (var member in customizerHolder.Type.GetProperties())
            {
                attributes = member.GetCustomAttributes(false);

                DataType(member, customizerHolder, attributes);
                FileOptions(member, customizerHolder, attributes);
                ImageSettings(member, customizerHolder, attributes);
                Template(member, customizerHolder, attributes);
                Id(member, customizerHolder, attributes);
                OnCreate(member, customizerHolder, attributes);
                OnUpdate(member, customizerHolder, attributes);
                OnSave(member, customizerHolder, attributes);
                OnDelete(member, customizerHolder, attributes);
                Cascade(member, customizerHolder, attributes);
                Column(member, customizerHolder, attributes);
                Display(member, customizerHolder, attributes);
                DisplayFormat(member, customizerHolder, attributes);
                Required(member, customizerHolder, attributes);
                ForeignKey(member, customizerHolder, attributes);
                Validation(member, customizerHolder, attributes);
                Timestamp(member, customizerHolder, attributes);
                ConcurrencyCheck(member, customizerHolder, attributes);
                DefaultOrder(member, customizerHolder, attributes);
                DefaultFilter(member, customizerHolder, attributes);
                Filterable(member, customizerHolder, attributes);
            }
        }
 private static void OnDelete(
     MemberInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<OnDeleteAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.OnDelete(attribute.Value);
         });
     }
 }
 private static void Cascade(
     MemberInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<CascadeAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.Cascade(attribute.DeleteOption);
         });
     }
 }
        private static void Template(
            MemberInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var uiHintAttribute = attributes.GetAttribute<UIHintAttribute>();
            var templateAttribute = attributes.GetAttribute<TemplateAttribute>();
            if (uiHintAttribute != null || templateAttribute != null)
            {
                string editor = null, display = null;
                if (uiHintAttribute != null)
                {
                    editor = display = uiHintAttribute.UIHint;
                }
                if (templateAttribute != null)
                {
                    if (!templateAttribute.DisplayTemplate.IsNullOrEmpty())
                    {
                        display = templateAttribute.DisplayTemplate;
                    }
                    if (!templateAttribute.EditorTemplate.IsNullOrEmpty())
                    {
                        editor = templateAttribute.EditorTemplate;
                    }
                }

                customizerHolder.Property(member, x =>
                {
                    x.Template(display, editor);
                });
            }
        }
Esempio n. 40
0
 private static void ConcurrencyCheck(
     PropertyInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<PropertyConcurrencyCheckAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.IsConcurrencyCheck();
         });
     }
 }
 public OneToManyCustomizer(PropertyPath propertyPath, ICustomizersHolder customizersHolder)
 {
     this.propertyPath = propertyPath;
     this.customizersHolder = customizersHolder;
 }
        private static void DataType(
            MemberInfo member,
            ICustomizersHolder customizerHolder,
            object[] attributes)
        {
            var dataTypeAttribute = attributes.GetAttribute<DataTypeAttribute>();
            if (dataTypeAttribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Type(dataTypeAttribute.DataType);
                });
                return;
            }

            var enumDataTypeAttribute = attributes.GetAttribute<EnumDataTypeAttribute>();
            if (enumDataTypeAttribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Enum(enumDataTypeAttribute.EnumType);
                });
                return;
            }

            var imageAttribute = attributes.GetAttribute<ImageSettingsAttribute>();
            if (imageAttribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Type(Core.DataType.Image);
                });
                return;
            }

            var fileAttribute = attributes.GetAttribute<FileAttribute>();
            if (fileAttribute != null)
            {
                customizerHolder.Property(member, x =>
                {
                    x.Type(fileAttribute.IsImage ?
                        Core.DataType.Image :
                        Core.DataType.File);
                });
                return;
            }
        }
 private static void DisplayFormat(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<RecordDisplayAttribute>();
     if (attribute != null)
     {
         customizerHolder.DisplayFormat(attribute.DisplayFormat);
     }
 }
 private static void Validation(
     PropertyInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var validators = attributes.GetAttributes<ValidationAttribute>();
     if (validators.IsNullOrEmpty() == false)
     {
         customizerHolder.Property(member, x =>
         {
             x.Validators(validators);
         });
     }
 }
 private static void ForeignKey(
     MemberInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<ForeignKeyAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.ForeignKey(attribute.Name);
         });
     }
 }
 private static void Editable(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<EditableAttribute>();
     if (attribute != null)
     {
         customizerHolder.Editable(attribute.AllowEdit);
     }
 }
 private static void Links(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<LinksAttribute>();
     if (attribute != null)
     {
         customizerHolder.Link(
             attribute.DisplayLink,
             attribute.EditLink,
             attribute.DeleteLink);
     }
 }
Esempio n. 48
0
 private static void DefaultFilter(
     PropertyInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<DefaultFilterAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.DefaultFilter(attribute.Value);
         });
     }
 }
Esempio n. 49
0
 private static void Timestamp(
     PropertyInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<TimestampAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.IsTimestamp();
         });
     }
 }
Esempio n. 50
0
 private static void Filterable(
     PropertyInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<FilterableAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.Filterable();
         });
     }
 }
 private static void ImageSettings(
     MemberInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var imageSettingsAttributes = attributes
         .GetAttributes<ImageSettingsAttribute>().ToList();
     if (imageSettingsAttributes.IsNullOrEmpty() == false)
     {
         customizerHolder.Property(member, x =>
         {
             foreach (var imageAttribute in imageSettingsAttributes)
             {
                 x.Image(
                     imageAttribute.Settings.SubPath,
                     imageAttribute.Settings.Width,
                     imageAttribute.Settings.Height);
             }
         });
     }
 }
 private static void Required(
     MemberInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<RequiredAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.Required(attribute.ErrorMessage);
         });
     }
 }
 private static void FileOptions(
     MemberInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var fileAttribute = attributes.GetAttribute<FileAttribute>();
     if (fileAttribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.File(
                 fileAttribute.NameCreation,
                 fileAttribute.MaxFileSize,
                 fileAttribute.IsImage,
                 fileAttribute.Path,
                 fileAttribute.AllowedFileExtensions);
         });
     }
 }
 private static void DisplayFormat(
     MemberInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<DisplayFormatAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.Format(attribute.DataFormatString);
         });
     }
 }
 private static void Groups(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<GroupsAttribute>();
     if (attribute != null)
     {
         var membersByGroup = customizerHolder.Type.GetProperties()
             .GroupBy(x => x.GetCustomAttribute<DisplayAttribute>()?.GroupName)
             .ToDictionary(x => x.Key, x => x.ToList());
         foreach (var group in attribute.Groups)
         {
             customizerHolder.PropertyGroup(group.TrimEnd('*'), group.EndsWith("*"), membersByGroup[group]);
         }
     }
 }
 private static void Display(
     MemberInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<DisplayAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.Display(attribute.Name, attribute.Description);
         });
     }
 }
Esempio n. 57
0
 private static void ConcurrencyCheck(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<EntityConcurrencyCheckAttribute>();
     if (attribute != null)
     {
         customizerHolder.ConcurrencyCheck();
     }
 }
 private static void Column(
     MemberInfo member,
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<ColumnAttribute>();
     if (attribute != null)
     {
         customizerHolder.Property(member, x =>
         {
             x.Column(attribute.Name);
         });
     }
 }
 private static void Deletable(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<DeletableAttribute>();
     if (attribute != null)
     {
         customizerHolder.Deletable(attribute.AllowDelete);
     }
 }
 private static void SoftDelete(
     ICustomizersHolder customizerHolder,
     object[] attributes)
 {
     var attribute = attributes.GetAttribute<SoftDeleteAttribute>();
     if (attribute != null)
     {
         customizerHolder.SoftDelete();
     }
 }