public void StoreProxyType(System.Type result, System.Type baseType, params System.Type[] baseInterfaces) { lock (syncObject) { var entry = new ProxyCacheEntry(baseType, baseInterfaces); cache[entry] = result; } }
public System.Type GetProxyType(System.Type baseType, params System.Type[] baseInterfaces) { lock (syncObject) { var entry = new ProxyCacheEntry(baseType, baseInterfaces); return cache[entry]; } }
public System.Type GetProxyType(System.Type baseType, params System.Type[] baseInterfaces) { lock (syncObject) { var entry = new ProxyCacheEntry(baseType, baseInterfaces); return(cache[entry]); } }
public void ProxyCacheEntity2FakeProxy2() { var entry = new ProxyCacheEntry(typeof(Entity2), null); TweakEntry(entry, _hashCode2); var result = _internalCache[entry]; Assert.AreEqual(typeof(Entity2FakeProxy2), result); }
public void ProxyCacheEntity1FakeProxy2() { var entry = new ProxyCacheEntry(typeof(Entity1), new[] { typeof(INHibernateProxy) }); TweakEntry(entry, _hashCode1); var result = _internalCache[entry]; Assert.AreEqual(typeof(Entity1FakeProxy2), result); }
public void ProxyCacheEntity4FakeProxy2() { var entry = new ProxyCacheEntry(typeof(Entity4), new[] { typeof(ISerializable) }); TweakEntry(entry, _hashCode2); var result = _internalCache[entry]; Assert.AreEqual(typeof(Entity4FakeProxy2), result); }
public bool Contains(System.Type baseType, params System.Type[] baseInterfaces) { if (baseType == null) { return false; } var entry = new ProxyCacheEntry(baseType, baseInterfaces); return cache.ContainsKey(entry); }
public bool TryGetProxyType(System.Type baseType, System.Type[] baseInterfaces, out System.Type proxyType) { proxyType = null; if (baseType == null) return false; var entry = new ProxyCacheEntry(baseType, baseInterfaces); return cache.TryGetValue(entry, out proxyType); }
public void ProxyCacheEntity5FakeProxy2() { // Interfaces order inverted on purpose: must be supported. var entry = new ProxyCacheEntry(typeof(Entity5), new[] { typeof(ISerializable), typeof(INHibernateProxy) }); TweakEntry(entry, _hashCode2); var result = _internalCache[entry]; Assert.AreEqual(typeof(Entity5FakeProxy2), result); }
public bool Contains(System.Type baseType, params System.Type[] baseInterfaces) { if (baseType == null) { return(false); } var entry = new ProxyCacheEntry(baseType, baseInterfaces); return(cache.ContainsKey(entry)); }
public bool TryGetProxyType(System.Type baseType, System.Type[] baseInterfaces, out System.Type proxyType) { proxyType = null; if (baseType == null) { return(false); } var entry = new ProxyCacheEntry(baseType, baseInterfaces); return(cache.TryGetValue(entry, out proxyType)); }
/// <summary> /// Allows to simulate a hashcode collision. Issue would be unpractical to test otherwise. /// Hashcode collision must be supported for avoiding unexpected and hard to reproduce failures. /// </summary> private void TweakEntry(ProxyCacheEntry entryToTweak, int hashcode) { // Though hashCode is a readonly field, this works at the time of this writing. If it starts breaking and cannot be fixed, // ignore those tests or throw them away. HashCodeField.SetValue(entryToTweak, hashcode); }
private void Inject(ProxyCacheEntry entryToTweak, int hashcode, System.Type result) { TweakEntry(entryToTweak, hashcode); _internalCache[entryToTweak] = result.GetTypeInfo(); }
public void StoreProxyType(TypeInfo result, System.Type baseType, params System.Type[] baseInterfaces) { var entry = new ProxyCacheEntry(baseType, baseInterfaces); ProxyFactory._cache[entry] = result; }
public TypeInfo GetProxyType(System.Type baseType, params System.Type[] baseInterfaces) { var entry = new ProxyCacheEntry(baseType, baseInterfaces); return(ProxyFactory._cache[entry]); }