Example #1
0
		public void StoreProxyType(System.Type result, System.Type baseType, params System.Type[] baseInterfaces)
		{
			lock (syncObject)
			{
				var entry = new ProxyCacheEntry(baseType, baseInterfaces);
				cache[entry] = result;
			}
		}
Example #2
0
		public System.Type GetProxyType(System.Type baseType, params System.Type[] baseInterfaces)
		{
			lock (syncObject)
			{
				var entry = new ProxyCacheEntry(baseType, baseInterfaces);
				return cache[entry];
			}
		}
Example #3
0
 public void StoreProxyType(System.Type result, System.Type baseType, params System.Type[] baseInterfaces)
 {
     lock (syncObject)
     {
         var entry = new ProxyCacheEntry(baseType, baseInterfaces);
         cache[entry] = result;
     }
 }
Example #4
0
 public System.Type GetProxyType(System.Type baseType, params System.Type[] baseInterfaces)
 {
     lock (syncObject)
     {
         var entry = new ProxyCacheEntry(baseType, baseInterfaces);
         return(cache[entry]);
     }
 }
Example #5
0
        public void ProxyCacheEntity2FakeProxy2()
        {
            var entry = new ProxyCacheEntry(typeof(Entity2), null);

            TweakEntry(entry, _hashCode2);
            var result = _internalCache[entry];

            Assert.AreEqual(typeof(Entity2FakeProxy2), result);
        }
Example #6
0
        public void ProxyCacheEntity1FakeProxy2()
        {
            var entry = new ProxyCacheEntry(typeof(Entity1), new[] { typeof(INHibernateProxy) });

            TweakEntry(entry, _hashCode1);
            var result = _internalCache[entry];

            Assert.AreEqual(typeof(Entity1FakeProxy2), result);
        }
Example #7
0
        public void ProxyCacheEntity4FakeProxy2()
        {
            var entry = new ProxyCacheEntry(typeof(Entity4), new[] { typeof(ISerializable) });

            TweakEntry(entry, _hashCode2);
            var result = _internalCache[entry];

            Assert.AreEqual(typeof(Entity4FakeProxy2), result);
        }
Example #8
0
		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);
		}
Example #9
0
		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);
		}
Example #10
0
        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);
        }
Example #11
0
        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));
        }
Example #12
0
        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));
        }
Example #13
0
 /// <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);
 }
Example #14
0
 private void Inject(ProxyCacheEntry entryToTweak, int hashcode, System.Type result)
 {
     TweakEntry(entryToTweak, hashcode);
     _internalCache[entryToTweak] = result.GetTypeInfo();
 }
Example #15
0
        public void StoreProxyType(TypeInfo result, System.Type baseType, params System.Type[] baseInterfaces)
        {
            var entry = new ProxyCacheEntry(baseType, baseInterfaces);

            ProxyFactory._cache[entry] = result;
        }
Example #16
0
        public TypeInfo GetProxyType(System.Type baseType, params System.Type[] baseInterfaces)
        {
            var entry = new ProxyCacheEntry(baseType, baseInterfaces);

            return(ProxyFactory._cache[entry]);
        }