예제 #1
0
        /// <summary>
        ///     创建默认
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="arg"></param>
        /// <param name="start"></param>
        /// <returns></returns>
        public T CreateDefault <T>(UniqueObjArg <TKey> arg, bool start) where T : class, TValue, new()
        {
            if (Exist(arg.Key))
            {
                return(null);
            }

            var ret = Create <T>(arg, start);

            ret.Born();
            Add(ret);
            EventDefaultObjCreated?.Invoke(ret);

            return(ret);
        }
예제 #2
0
        /// <summary>
        ///     非泛型创建默认
        /// </summary>
        /// <param name="type"></param>
        /// <param name="arg"></param>
        /// <param name="start"></param>
        /// <returns></returns>
        public IObj CreateDefault(Type type, UniqueObjArg <TKey> arg, bool start)
        {
            if (Exist(arg.Key))
            {
                return(null);
            }
            if (!type.IsSubclassOf(typeof(TValue)))
            {
                return(null);
            }

            var ret = Create(type, arg, start);

            ret.Born();

            var obj = ret as TValue;

            Add(obj);
            EventDefaultObjCreated?.Invoke(obj);

            return(ret);
        }