Exemple #1
0
        /// <summary>
        /// Gets the field metadata for a property of a model.
        /// </summary>
        /// <param name="modelType">The model type where the metadata is registered.</param>
        /// <param name="modelProperty">The property to get the metadata for.</param>
        /// <returns>Requested metadata, <c>null</c> if not found.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="modelType"/> or <paramref name="modelProperty"/> is null</exception>
        protected FieldMetadata GetFieldMetadata(Type modelType, ModelProperty modelProperty)
        {
            if (modelType == null)
            {
                throw new ArgumentNullException("modelType");
            }
            if (modelProperty == null)
            {
                throw new ArgumentNullException("modelProperty");
            }

            if (_metadataRepository == null)
            {
                _metadataRepository = ServiceRepository.Instance.FindService <IDataModelMetadataRepository>();
            }

            var metadata = _metadataRepository.GetModelMetadata(modelType);

            if (metadata != null)
            {
                return(metadata.GetFieldMetadata(modelProperty));
            }

            return(null);
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataModelSourceBase"/> class.
 /// </summary>
 protected DataModelSourceBase(IDataModelMetadataRepository metadataRepository, ILogger logger)
 {
     _items = new Dictionary <Type, DataModelCache>();
     _metadataRepository = metadataRepository;
     _logger             = logger;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseDataModelSource"/> class.
 /// </summary>
 /// <param name="metadataRepository">The repository containing metadata describing the models.</param>
 /// <param name="database">The database where the models are stored.</param>
 public DatabaseDataModelSource(IDataModelMetadataRepository metadataRepository, IDatabase database)
     : base(metadataRepository, Logger.GetLogger("DatabaseDataModelSource"))
 {
     _database = database;
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseDataModelSource"/> class.
 /// </summary>
 /// <param name="metadataRepository">The repository containing metadata describing the models.</param>
 public MemoryDataModelSource(IDataModelMetadataRepository metadataRepository)
     : base(metadataRepository, Logger.GetLogger("MemoryDataModelSource"))
 {
 }