public void ApplyClientBehavior(OperationDescription description, ClientOperation runtime)
 {
     if (innerFormatterBehavior != null && runtime.Formatter == null)
     {
         // no formatter has been applied yet
         innerFormatterBehavior.ApplyClientBehavior(description, runtime);
     }
 }
Exemplo n.º 2
0
        public void ApplyClientBehavior(OperationDescription description,
                                        ClientOperation proxy)
        {
            _curBehavior = new CustomDataContractSerializerOperationBehavior(description);
            IOperationBehavior innerBehavior = _curBehavior;

            innerBehavior.ApplyClientBehavior(description, proxy);
        }
Exemplo n.º 3
0
        static void BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch)
        {
            if (!(((proxy == null) != (dispatch == null))))
            {
                throw Fx.AssertAndThrowFatal("DispatcherBuilder.BindOperations: ((proxy == null) != (dispatch == null))");
            }

            MessageDirection local = (proxy == null) ? MessageDirection.Input : MessageDirection.Output;

            for (int i = 0; i < contract.Operations.Count; i++)
            {
                OperationDescription operation = contract.Operations[i];
                MessageDescription   first     = operation.Messages[0];

                if (first.Direction != local)
                {
                    if (proxy == null)
                    {
                        proxy = dispatch.CallbackClientRuntime;
                    }

                    ClientOperation proxyOperation = proxy.Operations[operation.Name];
                    Fx.Assert(proxyOperation != null, "");

                    for (int j = 0; j < operation.Behaviors.Count; j++)
                    {
                        IOperationBehavior behavior = operation.Behaviors[j];
                        behavior.ApplyClientBehavior(operation, proxyOperation);
                    }
                }
                else
                {
                    if (dispatch == null)
                    {
                        dispatch = proxy.CallbackDispatchRuntime;
                    }

                    DispatchOperation dispatchOperation = null;
                    if (dispatch.Operations.Contains(operation.Name))
                    {
                        dispatchOperation = dispatch.Operations[operation.Name];
                    }
                    if (dispatchOperation == null && dispatch.UnhandledDispatchOperation != null && dispatch.UnhandledDispatchOperation.Name == operation.Name)
                    {
                        dispatchOperation = dispatch.UnhandledDispatchOperation;
                    }

                    if (dispatchOperation != null)
                    {
                        for (int j = 0; j < operation.Behaviors.Count; j++)
                        {
                            IOperationBehavior behavior = operation.Behaviors[j];
                            behavior.ApplyDispatchBehavior(operation, dispatchOperation);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 public void ApplyClientBehavior(OperationDescription description, ClientOperation runtime)
 {
     if (innerFormatterBehavior != null && runtime.Formatter == null)
     {
         // no formatter has been applied yet
         innerFormatterBehavior.ApplyClientBehavior(description, runtime);
     }
     runtime.Formatter = new QueryStringFormatter(description.Name, runtime.SyncMethod.GetParameters(), runtime.Formatter, runtime.Action, endpointAddress);
 }
Exemplo n.º 5
0
 public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
 {
     if (clientOperation == null)
     {
         throw new ArgumentNullException("clientOperation");
     }
     if (_innerFormatterBehavior != null && clientOperation.Formatter == null)
     {
         _innerFormatterBehavior.ApplyClientBehavior(operationDescription, clientOperation);
     }
     clientOperation.Formatter = new WcfClientMessageFormatter(clientOperation.Formatter,
                                                               new WcfMessageEncodingContext(_endpoint, operationDescription, clientOperation),
                                                               _messageEncodingController);
 }
Exemplo n.º 6
0
        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            foreach (OperationDescription operation in endpoint.Contract.Operations)
            {
                IOperationBehavior serializerBehavior = operation.Behaviors.Find <XmlSerializerOperationBehavior>();
                if (null == serializerBehavior)
                {
                    serializerBehavior = operation.Behaviors.Find <DataContractSerializerOperationBehavior>();
                }
                serializerBehavior.ApplyClientBehavior(operation, clientRuntime.Operations[operation.Name]);
            }

            foreach (ClientOperation operation in clientRuntime.Operations)
            {
                operation.Formatter = new CompressionMessageFormatter(this.MessageCompressor, null, operation.Formatter);
            }
        }
Exemplo n.º 7
0
    public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
    {
        //var serializerBehavior = operationDescription.Behaviors.Find<DataContractSerializerOperationBehavior>();
        IOperationBehavior serializerBehavior = operationDescription.Behaviors.Find <XmlSerializerOperationBehavior>();

        if (serializerBehavior == null)
        {
            serializerBehavior = operationDescription.Behaviors.Find <DataContractSerializerOperationBehavior>();
        }

        if (clientOperation.Formatter == null)
        {
            serializerBehavior.ApplyClientBehavior(operationDescription, clientOperation);
        }

        IClientMessageFormatter innerClientFormatter = clientOperation.Formatter;

        clientOperation.Formatter = new EnvelopeNamespaceMessageFormatter(innerClientFormatter)
        {
            EnvelopeNamespaces = EnvelopeNamespaces
        };
    }
 /// <summary>
 /// Implements a modification or extension of the client accross an operation.
 /// </summary>
 /// <param name="operationDescription">The operation being examined. Use for examination only. If the operation
 /// description is modified, the results are undefined.</param>
 /// <param name="clientOperation">The run-time object that exposes customization properties for the operation
 /// described by <paramref name="operationDescription"/>.</param>
 public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
 {
     operationBehavior.ApplyClientBehavior(operationDescription, clientOperation);
 }