/// <summary> /// 创建 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="arg"></param> /// <param name="start"></param> /// <returns></returns> public T Create <T>(UniqueObjArg <TKey> arg, bool start = false) where T : class, TValue, new() { if (Exist(arg.Key)) { return(null); } var ret = New <T>(arg, start); Add(ret); EventObjCreated?.Invoke(ret); return(ret); }
/// <summary> /// 非泛型创建 /// </summary> /// <param name="type"></param> /// <param name="arg"></param> /// <param name="start"></param> /// <returns></returns> public IObj Create(Type type, UniqueObjArg <TKey> arg, bool start = false) { if (Exist(arg.Key)) { return(null); } if (!type.IsSubclassOf(typeof(TValue))) { return(null); } var ret = New(type, arg, start); var obj = ret as TValue; Add(obj); EventObjCreated?.Invoke(obj); return(ret); }