/// <summary> /// 向引用池中追加指定数量的引用。 /// </summary> /// <param name="referenceType">引用类型。</param> /// <param name="count">追加数量。</param> public static void Add(Type referenceType, int count) { InternalCheckReferenceType(referenceType); ReferenceCollection referenceCollection = GetReferenceCollection(referenceType.FullName); while (count-- > 0) { referenceCollection.Release((IReference)Activator.CreateInstance(referenceType)); } }
/// <summary> /// 释放对象 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="force"></param> public static void Release <T>(bool force = false) { System.Type referenceType = typeof(T); ReferenceCollection referenceCollection = GetReferenceCollection(referenceType); if (referenceCollection == null) { return; } if (referenceCollection.Release(force)) { _referenceCollections.Remove(referenceType); } }