예제 #1
0
 /// <summary>
 /// Registers default search handler that for all types creates model definition by <see cref="ReflectionModelDefinitionBuilder"/>.
 /// </summary>
 /// <param name="collection">Model definition collection to register search handler to.</param>
 /// <param name="metadataReaders">Collection of metadata readers for <see cref="ReflectionModelDefinitionBuilder"/>.</param>
 /// <returns></returns>
 public static TypeModelDefinitionCollection AddReflectionSearchHandler(this TypeModelDefinitionCollection collection, AttributeMetadataReaderCollection metadataReaders)
 {
     Ensure.NotNull(collection, "collection");
     Ensure.NotNull(metadataReaders, "metadataReaders");
     collection.AddSearchHandler((Type type, out IModelDefinition model) =>
     {
         model = new ReflectionModelDefinitionBuilder(type, metadataReaders).Create();
         return(true);
     });
     return(collection);
 }
        /// <summary>
        /// Creates model definition for <see cref="modelType"/>.
        /// </summary>
        /// <param name="modelType">Type to create model definition from.</param>
        /// <returns>Model definition for <see cref="modelType"/>.</returns>
        public IModelDefinition Create(Type modelType)
        {
            ReflectionModelDefinitionBuilder builder = new ReflectionModelDefinitionBuilder(modelType, MetadataReaderCollection);

            return(builder.Create());
        }