예제 #1
0
        public IClientBuilder <TContract> GenerateClientBuilder <TContract>()
        {
            var serviceType = typeof(TContract);

            Type clientBuilderType;

            lock (ProxyAssembly.SyncRoot)
            {
                clientBuilderType = ProxyAssembly.DefaultModule.GetType(ContractDescription.GetClientBuilderClassName(serviceType), false, false) !;
                if (clientBuilderType == null)
                {
                    var(description, contractType) = GenerateContract(serviceType);
                    var clientType = new EmitClientBuilder(description, contractType).Build(ProxyAssembly.DefaultModule);
                    clientBuilderType = new EmitClientBuilderBuilder(description, contractType, clientType).Build(ProxyAssembly.DefaultModule);
                }
            }

            return((IClientBuilder <TContract>)Activator.CreateInstance(clientBuilderType));
        }