コード例 #1
0
        /// <summary>
        /// Registeres metadata with specific <see cref="metadataBuilder"/>
        ///
        ///
        /// <exception cref="MetadataRegistrationException"></exception>
        /// <exception cref="MetadataAlreadyExistsException"></exception>
        ///
        /// </summary>
        /// <param name="metadataBuilder">The metadata builder</param>
        protected internal void RegisterMetadata([NotNull] IMetadataBuilder metadataBuilder)
        {
            Guard.AgainstNullReference <MetadataRegistrationException>(metadataBuilder, "metadataBuilder",
                                                                       NULL_METADATA_BUILDER_MESSAGE);

            var metadataType = metadataBuilder.TypeToBuild;

            if (TypeHelper.IsPrimitiveType(metadataType))
            {
                Guard.Throw <MetadataRegistrationException>(PRIMITIVE_TYPE_MESSAGE);
            }

            if (this._collection.ContainsKey(metadataBuilder.TypeToBuild))
            {
                Guard.Throw <MetadataAlreadyExistsException>(string.Format(METADATA_CONFLICT_MESSAGE_PATTERN, metadataBuilder.TypeToBuild));
            }

            this._collection.Add(metadataType, metadataBuilder.Build());
        }
コード例 #2
0
 public Metadata Build()
 {
     OnModelCreating(_metadataBuilder);
     return(_metadataBuilder.Build());
 }