public AssociationMetadata(MetadataClass <TEntity> metadata, string member)
        {
            this.metadata = metadata;
            this.member   = member;

            ResetAttribute();
        }
        public static MemberValidationMetadata <TEntity> Validation <TEntity, TMember>(
            this MetadataClass <TEntity> metadata, Expression <Func <TEntity, TMember> > memberReference) where TEntity : class
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            return(new MemberValidationMetadata <TEntity>(metadata, GetMemberName(memberReference)));
        }
        public static ValidationMetadata <TEntity> Validation <TEntity>(this MetadataClass <TEntity> metadata)
            where TEntity : class
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            return(new ValidationMetadata <TEntity>(metadata));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Copies the member metadata and entity metadata of the provided source MetadataClass to this instance.
 /// </summary>
 /// <param name="source"></param>
 internal void Merge(MetadataClass source)
 {
     foreach (var member in source._memberMetadata.Keys)
     {
         foreach (var attr in source._memberMetadata[member].ToList())
         {
             AddMetadata(member, attr);
         }
     }
     EntityMetadata.AddRange(source.EntityMetadata);
 }
        public MetadataClass <T> Entity <T>() where T : class
        {
            MetadataClass metadataClass = Fetch <T>();

            if (metadataClass == null)
            {
                metadataClass = new AnonymousMetadataClass <T> {
                    Container = this
                };
                metaData.Add(metadataClass);
            }
            return(metadataClass as MetadataClass <T>);
        }
        public static MemberUIHintsMetadata <TEntity> UIHints <TEntity>(
            this MetadataClass <TEntity> metadata, string memberName) where TEntity : class
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }
            if (String.IsNullOrEmpty(memberName))
            {
                throw new ArgumentNullException("memberName");
            }

            return(new MemberUIHintsMetadata <TEntity>(metadata, memberName));
        }
 /// <summary>
 /// Add metadata to subtypes that is derived from base types
 /// </summary>
 internal void ResolveInheritedMetadata()
 {
     foreach (MetadataClass metadataClass in metaData)
     {
         Type baseType = metadataClass.EntityType.BaseType;
         while (baseType != null)
         {
             MetadataClass baseMetadataClass = metaData.SingleOrDefault(mdClass => mdClass.EntityType == baseType);
             if (baseMetadataClass != null)
             {
                 metadataClass.Merge(baseMetadataClass);
             }
             baseType = baseType.BaseType;
         }
     }
 }
        /// <summary>
        /// Finds the MetadataClass for the provided type. That is, either the metadata class defining T, or else the metadata class
        /// of the closest base class of type.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        internal MetadataClass Resolve(Type type)
        {
            MetadataClass result = null;

            foreach (MetadataClass metadataClass in metaData)
            {
                if (type == metadataClass.EntityType)
                {
                    return(metadataClass);
                }
                if (type.IsSubclassOf(metadataClass.EntityType))
                {
                    if (result == null || metadataClass.EntityType.IsSubclassOf(result.EntityType))
                    {
                        result = metadataClass;
                    }
                }
            }
            return(result);
        }
 public FluentTypeDescriptor(MetadataClass metadata, ICustomTypeDescriptor parentDescriptor)
     : base(parentDescriptor)
 {
     _metadata = metadata;
 }
Ejemplo n.º 10
0
 internal MemberValidationMetadata(MetadataClass <TEntity> metadata, string memberName)
 {
     _metadata   = metadata;
     _memberName = memberName;
 }
 public MemberProjectionMetadata(MetadataClass <TEntity> metadata, string memberName)
 {
     _metadata  = metadata;
     MemberName = memberName;
 }
 internal ValidationMetadata(MetadataClass <TEntity> metadata)
 {
     _metadata = metadata;
 }
 public static MemberProjectionCollectionMetadata <TModel, TMember> Projection <TModel, TMember>(this MetadataClass <TModel> metadata, Expression <Func <TModel, ICollection <TMember> > > memberReference)
     where TModel : class
     where TMember : class
 {
     if (metadata == null)
     {
         throw new ArgumentNullException("metadata");
     }
     return(new MemberProjectionCollectionMetadata <TModel, TMember>(metadata, GetMemberName(memberReference)));
 }
 public void Add <T>(MetadataClass <T> metadataClass)
     where T : class
 {
     Entity <T>().Merge(metadataClass);
 }
Ejemplo n.º 15
0
 internal MemberUIHintsMetadata(MetadataClass <TEntity> metadata, string memberName)
 {
     _metadata   = metadata;
     _memberName = memberName;
 }