public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) { var protoBinding = endpoint.Binding as ProtoBufBinding; if (protoBinding == null) throw new ConfigurationException("The endpoint behaviour, ProtoBufBindingEndpointBehaviour, can only be applied to an endpoint which has ProtoBufBinding as its binding."); foreach (var clientOperation in clientRuntime.ClientOperations) { var compressionBehaviour = protoBinding.GetOperationCompressionBehaviour(clientOperation.Name); var contractInfo = ContractInfo.FromAction(clientOperation.Action); var serviceContract = TypeFinder.FindServiceContract(contractInfo.ServiceContractName); var paramTypes = TypeFinder.GetContractParamTypes(serviceContract, contractInfo.OperationContractName, contractInfo.Action, false); var formatter = new ProtoBufClientFormatter(new List<TypeInfo>(paramTypes), contractInfo.Action, compressionBehaviour); clientOperation.Formatter = formatter; clientOperation.SerializeRequest = true; clientOperation.DeserializeReply = true; } }
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) { var protoBinding = endpoint.Binding as ProtoBufBinding; if (protoBinding == null) { throw new ConfigurationException("The endpoint behaviour, ProtoBufBindingEndpointBehaviour, can only be applied to an endpoint which has ProtoBufBinding as its binding."); } foreach (var clientOperation in clientRuntime.ClientOperations) { var compressionBehaviour = protoBinding.GetOperationCompressionBehaviour(clientOperation.Name); var contractInfo = ContractInfo.FromAction(clientOperation.Action); var serviceContract = TypeFinder.FindServiceContract(contractInfo.ServiceContractName); var paramTypes = TypeFinder.GetContractParamTypes(serviceContract, contractInfo.OperationContractName, contractInfo.Action, false); var formatter = new ProtoBufClientFormatter(new List <TypeInfo>(paramTypes), contractInfo.Action, compressionBehaviour); clientOperation.Formatter = formatter; clientOperation.SerializeRequest = true; clientOperation.DeserializeReply = true; } }