コード例 #1
0
        public static Type GetProxyType <T>() where T : class
        {
            lock (CreateProxyLock)
            {
                var interfaceType = typeof(T);

                if (!interfaceType.IsInterface)
                {
                    throw new ProxyTypeMustBeInterfaceException();
                }

                Type proxyType;
                if (!ProxyCache.TryGetValue(interfaceType, out proxyType))
                {
                    proxyType = ProxyGenerator.CreateProxy <T>();
                    ProxyCache[interfaceType] = proxyType;
                }

                return(proxyType);
            }
        }