public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { 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 operation in endpointDispatcher.DispatchRuntime.Operations) { var compressionBehaviour = protoBinding.GetOperationCompressionBehaviour(operation.Name); var contractInfo = ContractInfo.FromAction(operation.Action); var serviceContract = TypeFinder.FindServiceContract(contractInfo.ServiceContractName); var paramTypes = TypeFinder.GetContractParamTypes(serviceContract, contractInfo.OperationContractName, contractInfo.Action, false); var formatter = new ProtoBufDispatchFormatter(new List<TypeInfo>(paramTypes), contractInfo.Action, compressionBehaviour); operation.Formatter = formatter; operation.DeserializeRequest = true; operation.SerializeReply = true; } }
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { 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 operation in endpointDispatcher.DispatchRuntime.Operations) { var compressionBehaviour = protoBinding.GetOperationCompressionBehaviour(operation.Name); var contractInfo = ContractInfo.FromAction(operation.Action); var serviceContract = TypeFinder.FindServiceContract(contractInfo.ServiceContractName); var paramTypes = TypeFinder.GetContractParamTypes(serviceContract, contractInfo.OperationContractName, contractInfo.Action, false); var formatter = new ProtoBufDispatchFormatter(new List <TypeInfo>(paramTypes), contractInfo.Action, compressionBehaviour); operation.Formatter = formatter; operation.DeserializeRequest = true; operation.SerializeReply = true; } }