예제 #1
0
        private static Type GetModelType(CachedModelMetadata <TPrototypeCache> prototype)
        {
            if (prototype == null)
            {
                throw Error.ArgumentNull("prototype");
            }

            return(prototype.ModelType);
        }
예제 #2
0
        private static string GetPropertyName(CachedModelMetadata <TPrototypeCache> prototype)
        {
            if (prototype == null)
            {
                throw Error.ArgumentNull("prototype");
            }

            return(prototype.PropertyName);
        }
예제 #3
0
        private static ModelMetadataProvider GetProvider(CachedModelMetadata <TPrototypeCache> prototype)
        {
            if (prototype == null)
            {
                throw Error.ArgumentNull("prototype");
            }

            return(prototype.Provider);
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CachedDataAnnotationsMetadataAttributes"/> class.
        /// </summary>
        /// <param name="prototype">The prototype.</param>
        /// <param name="modelAccessor">The model accessor.</param>
        /// <remarks>Constructor for creating real instances of the metadata class based on a prototype.</remarks>
        protected CachedModelMetadata(CachedModelMetadata <TPrototypeCache> prototype, Func <object> modelAccessor)
            : base(GetProvider(prototype), GetContainerType(prototype), modelAccessor, GetModelType(prototype), GetPropertyName(prototype))
        {
            if (prototype == null)
            {
                throw Error.ArgumentNull("prototype");
            }

            this.PrototypeCache = prototype.PrototypeCache;

            this.isComplexType         = prototype.IsComplexType;
            this.isComplexTypeComputed = true;
        }