示例#1
0
        /// <summary>
        /// Registers a new <see cref="DynamicObjectType"/> with this
        /// <see cref="DynamicMetadataProvider"/>.
        /// </summary>
        /// <param name="fullName"></param>
        /// <param name="clrType"></param>
        /// <returns>
        /// Returns a new <see cref="ObjectType"/>
        /// </returns>
        public ObjectType RegisterObjectType(string fullName,
                                             Type clrType)
        {
            var objType = DynamicObjectType.Create(this, fullName, clrType);

            this.RegisterObjectType(this, objType);
            return(objType);
        }
示例#2
0
        /// <summary>
        /// Registers a new <see cref="DynamicObjectType"/> with this
        /// <see cref="DynamicMetadataProvider"/>.
        /// </summary>
        /// <param name="metadataProvider"></param>
        /// <param name="fullName"></param>
        /// <param name="clrType"></param>
        /// <returns>
        /// Returns a new <see cref="ObjectType"/>
        /// </returns>
        public ObjectType RegisterObjectType(IMetadataProvider metadataProvider,
                                             string fullName,
                                             Type clrType)
        {
            var objType = DynamicObjectType.Create(metadataProvider, fullName, clrType);

            this.RegisterObjectType(metadataProvider, objType);
            return(objType);
        }
示例#3
0
        /// <summary>
        /// Registers the given <see cref="DynamicObjectType"/> with this
        /// <see cref="DynamicMetadataProvider"/>.
        /// </summary>
        /// <param name="metadataProvider"></param>
        /// <param name="objType"></param>
        public void RegisterObjectType(IMetadataProvider metadataProvider, DynamicObjectType objType)
        {
            if (objType == null)
            {
                throw new ArgumentNullException(nameof(objType));
            }

            if (this.objTypes.ContainsKey(objType.FullName))
            {
                var msg = string.Format("{0} is already registered with this dynamic metadata provider", objType.FullName);
                throw new InvalidOperationException(msg);
            }

            // Attach the metadata provider
            if (metadataProvider == null)
            {
                metadataProvider = this;
            }
            objType.AttachMetadataProvider(metadataProvider);

            this.objTypes.Add(objType.FullName, objType);
        }
示例#4
0
 /// <summary>
 /// Registers the given <see cref="DynamicObjectType"/> with this
 /// <see cref="DynamicMetadataProvider"/>.
 /// </summary>
 /// <param name="objType"></param>
 public void RegisterObjectType(DynamicObjectType objType)
 {
     this.RegisterObjectType(this, objType);
 }