Exemple #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;
			}
		}
Exemple #2
0
		public System.Type GetProxyType(System.Type baseType, params System.Type[] baseInterfaces)
		{
			lock (syncObject)
			{
				var entry = new ProxyCacheEntry(baseType, baseInterfaces);
				return cache[entry];
			}
		}
Exemple #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;
     }
 }
Exemple #4
0
 public System.Type GetProxyType(System.Type baseType, params System.Type[] baseInterfaces)
 {
     lock (syncObject)
     {
         var entry = new ProxyCacheEntry(baseType, baseInterfaces);
         return(cache[entry]);
     }
 }
Exemple #5
0
        public void ProxyCacheEntity2FakeProxy2()
        {
            var entry = new ProxyCacheEntry(typeof(Entity2), null);

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

            Assert.AreEqual(typeof(Entity2FakeProxy2), result);
        }
Exemple #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);
        }
Exemple #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);
        }
		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);
		}
Exemple #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);
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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);
 }
Exemple #14
0
 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]);
        }