public IServiceEndpointBinder <TService> GenerateServiceEndpointBinder <TService>(Type?serviceInstanceType) { if (serviceInstanceType != null && !ServiceContract.IsServiceInstanceType(serviceInstanceType)) { throw new ArgumentOutOfRangeException(nameof(serviceInstanceType)); } var serviceType = typeof(TService); ContractDescription description; Type contractType; Type channelType; lock (ProxyAssembly.SyncRoot) { (description, contractType) = GenerateContract(serviceType); channelType = ProxyAssembly.DefaultModule.GetType(ContractDescription.GetEndpointClassName(serviceType), false, false) !; if (channelType == null) { var serviceBuilder = new EmitServiceEndpointBuilder(description); channelType = serviceBuilder.Build(ProxyAssembly.DefaultModule, Logger); } } return(new EmitServiceEndpointBinder <TService>(description, serviceInstanceType, contractType, channelType, Logger)); }
public void BeforeAllTest() { var description = new ContractDescription(typeof(IContract)); var contractType = new EmitContractBuilder(description).Build(ProxyAssembly.DefaultModule, nameof(EmitServiceEndpointBuilderTest) + "Contract"); var sut = new EmitServiceEndpointBuilder(description); ChannelType = sut.Build(ProxyAssembly.DefaultModule, className: nameof(EmitServiceEndpointBuilderTest) + "Channel"); var contract = EmitContractBuilder.CreateFactory(contractType)(DataContractMarshallerFactory.Default); Channel = EmitServiceEndpointBuilder.CreateFactory(ChannelType)(); }