Exemple #1
0
        /// <summary>
        ///     注册扩展类型数据valueStored
        /// </summary>
        /// <param name="type">数据处理器类型</param>
        /// <exception cref="ArgumentNullException">参数不能为空</exception>
        public static void Regist(Type type)
        {
            BaseValueStored valueStored = (BaseValueStored)type.GetTypeInfo().Assembly.CreateInstance(type.FullName);

            if (valueStored == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (valueStored.TypeId <= MetadataObjectSetting.TYPE_BOUNDARY)
            {
                throw new ArgumentException(string.Format("#Extensionable Type id can not be setted in System Type range, boundary type id is {0}", MetadataObjectSetting.TYPE_BOUNDARY));
            }
            if (valueStored.Clone() == null)
            {
                throw new NullReferenceException("#There is a null reference object instance when called Clone method.");
            }
            if (!(valueStored.Clone().GetType().GetTypeInfo().IsSubclassOf(typeof(BaseValueStored))))
            {
                throw new ArgumentException("#Generated instance of Clone method was not the sub class of BaseValueStored");
            }
            _valueStoreds[valueStored.TypeId] = valueStored;
        }