static void task() { for (int i = 0; i < totalTimes; i++) { ObjectCache <string, object> .Acquire(Guid.NewGuid().ToString(), () => new object()); } }
public static ClassExtensionInfo Acquire(Type classExtensionType) { return(ObjectCache <Type, ClassExtensionInfo> .Acquire(classExtensionType, () => { return new ClassExtensionInfo(classExtensionType); })); }
static void task() { for (int i = 0; i < totalTimes; i++) { ObjectCache <string, float> .Acquire(Guid.NewGuid().ToString(), () => 1.0F); } }
public void ClearCacheTest() { _ = ObjectCache <string, object> .Acquire("1", () => new object()); _ = ObjectCache <string, object> .Acquire("2", () => new object()); ObjectCache <string, object> .ClearCache(); Assert.IsTrue(ObjectCache <string, object> .CachedCount == 0); }
public void CountTest() { _ = ObjectCache <string, object> .Acquire("1", () => new object()); _ = ObjectCache <string, object> .Acquire("2", () => new object()); Assert.IsTrue(ObjectCache <string, object> .CachedCount == 2); _ = ObjectCache <int, int> .Acquire(0, () => 0); _ = ObjectCache <int, int> .Acquire(1, () => 1); Assert.IsTrue(ObjectCache <int, int> .CachedCount == 2); }
public void ReferenceEqualsTest() { var acquire0_0 = ObjectCache <int, object> .Acquire(0, () => new object()); var acquire0_1 = ObjectCache <int, object> .Acquire(0, () => new object()); Assert.IsTrue(ReferenceEquals(acquire0_0, acquire0_1)); var acquire1 = ObjectCache <int, object> .Acquire(1, () => new object()); var acquire2 = ObjectCache <int, object> .Acquire(2, () => new object()); Assert.IsFalse(ReferenceEquals(acquire1, acquire2)); acquire0_0 = ObjectCache <int, object> .Acquire(0, () => new object()); acquire0_1 = ObjectCache <int, object> .Acquire(0, () => new object()); Assert.IsTrue(ReferenceEquals(acquire0_0, acquire0_1)); }
public static ClassTextReader Acquire(Type t) { return(ObjectCache <Type, ClassTextReader> .Acquire(t, () => new ClassTextReader(t))); }