public CompressionMessageFormatter(MessageCompressor messageCompressor,
 IDispatchMessageFormatter innerDispatchMessageFormatter, IClientMessageFormatter innerClientMessageFormatter)
 {
     this.MessageCompressor = messageCompressor;
     this.InnerDispatchMessageFormatter = innerDispatchMessageFormatter;
     this.InnerClientMessageFormatter = innerClientMessageFormatter;
 }
Пример #2
0
        internal ProxyOperationRuntime(ClientOperation operation, ImmutableClientRuntime parent)
        {
            if (operation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
            }
            if (parent == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
            }

            _parent        = parent;
            _formatter     = operation.Formatter;
            _isInitiating  = operation.IsInitiating;
            _isOneWay      = operation.IsOneWay;
            _isTerminating = operation.IsTerminating;
            _isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled;
            _name = operation.Name;
            _parameterInspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors);

            _faultFormatter   = operation.FaultFormatter;
            _serializeRequest = operation.SerializeRequest;
            _deserializeReply = operation.DeserializeReply;
            _action           = operation.Action;
            _replyAction      = operation.ReplyAction;
            _beginMethod      = operation.BeginMethod;
            _syncMethod       = operation.SyncMethod;
            _taskMethod       = operation.TaskMethod;
            this.TaskTResult  = operation.TaskTResult;

            if (_beginMethod != null)
            {
                _inParams = ServiceReflector.GetInputParameters(_beginMethod, true);
                if (_syncMethod != null)
                {
                    _outParams = ServiceReflector.GetOutputParameters(_syncMethod, false);
                }
                else
                {
                    _outParams = Array.Empty <ParameterInfo>();
                }
                _endOutParams = ServiceReflector.GetOutputParameters(operation.EndMethod, true);
                _returnParam  = operation.EndMethod.ReturnParameter;
            }
            else if (_syncMethod != null)
            {
                _inParams    = ServiceReflector.GetInputParameters(_syncMethod, false);
                _outParams   = ServiceReflector.GetOutputParameters(_syncMethod, false);
                _returnParam = _syncMethod.ReturnParameter;
            }

            if (_formatter == null && (_serializeRequest || _deserializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.ClientRuntimeRequiresFormatter0, _name)));
            }
        }
        internal ProxyOperationRuntime(ClientOperation operation, ImmutableClientRuntime parent)
        {
            if (operation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
            }
            if (parent == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
            }

            this.parent        = parent;
            this.formatter     = operation.Formatter;
            this.isInitiating  = operation.IsInitiating;
            this.isOneWay      = operation.IsOneWay;
            this.isTerminating = operation.IsTerminating;
            this.isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled;
            this.name = operation.Name;
            this.parameterInspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors);

            this.faultFormatter   = operation.FaultFormatter;
            this.serializeRequest = operation.SerializeRequest;
            this.deserializeReply = operation.DeserializeReply;
            this.action           = operation.Action;
            this.replyAction      = operation.ReplyAction;
            this.beginMethod      = operation.BeginMethod;
            this.syncMethod       = operation.SyncMethod;
            this.taskMethod       = operation.TaskMethod;
            this.TaskTResult      = operation.TaskTResult;

            if (this.beginMethod != null)
            {
                this.inParams = ServiceReflector.GetInputParameters(this.beginMethod, true);
                if (this.syncMethod != null)
                {
                    this.outParams = ServiceReflector.GetOutputParameters(this.syncMethod, false);
                }
                else
                {
                    this.outParams = NoParams;
                }
                this.endOutParams = ServiceReflector.GetOutputParameters(operation.EndMethod, true);
                this.returnParam  = operation.EndMethod.ReturnParameter;
            }
            else if (this.syncMethod != null)
            {
                this.inParams    = ServiceReflector.GetInputParameters(this.syncMethod, false);
                this.outParams   = ServiceReflector.GetOutputParameters(this.syncMethod, false);
                this.returnParam = this.syncMethod.ReturnParameter;
            }

            if (this.formatter == null && (serializeRequest || deserializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ClientRuntimeRequiresFormatter0, this.name)));
            }
        }
 public RestClientMessageFormatter(IClientMessageFormatter actual
     , OperationDescription description
     , RestWebContentTypeMapper mapper
     , ConnectionSettings configuration)
 {
     this.Original = actual;
     this.Description = description;
     this.Mapper = mapper;
     this.Configuration = configuration;
 }
Пример #5
0
 public WcfClientMessageFormatter(IClientMessageFormatter innerClientFormatter,
                                  WcfMessageEncodingContext context, IWcfMessageEncodingController controller)
 {
     if (innerClientFormatter == null)
     {
         throw new ArgumentNullException("innerClientFormatter");
     }
     _innerClientFormatter = innerClientFormatter;
     _context    = context;
     _controller = controller;
 }
Пример #6
0
 internal void SetFormatter(IClientMessageFormatter formatter)
 {
     if (this.requestFormatter != null)
     {
         this.requestFormatter.Formatter = formatter;
     }
     else
     {
         this.lazyFormatter = formatter;
     }
 }
Пример #7
0
 internal void SetFormatter(IClientMessageFormatter formatter)
 {
     if (this.requestFormatter != null)
     {
         this.requestFormatter.Formatter = formatter;
     }
     else
     {
         // we save the formatter and set the requestFormatter.Formatter later
         this.lazyFormatter = formatter;
     }
 }
 public ContentTypeSettingClientMessageFormatter(string outgoingContentType, IClientMessageFormatter innerFormatter)
 {
     if (outgoingContentType == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("outgoingContentType");
     }
     if (innerFormatter == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("innerFormatter");
     }
     this.outgoingContentType = outgoingContentType;
     this.innerFormatter      = innerFormatter;
 }
Пример #9
0
        public TChannel CreateChannel()
        {
            MessageEncoderFactory          encoderFactory = ComponentBuilder.GetMessageEncoderFactory(MessageVersion.Default, Encoding.UTF8);
            ServiceChannelProxy <TChannel> proxy          = new ServiceChannelProxy <TChannel>(this.Address, MessageVersion.Default, encoderFactory);
            ContractDescription            contract       = ContractDescription.GetContract(typeof(TChannel));

            foreach (OperationDescription operation in contract.Operations)
            {
                IClientMessageFormatter messageFormatter = (IClientMessageFormatter)ComponentBuilder.GetFormatter(operation, true);
                proxy.MessageFormatters.Add(operation.Name, messageFormatter);
            }
            return((TChannel)proxy.GetTransparentProxy());
        }
 public DemultiplexingClientMessageFormatter(IDictionary<WebContentFormat, IClientMessageFormatter> formatters, IClientMessageFormatter defaultFormatter)
 {
     if (formatters == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("formatters");
     }
     this.formatters = new Dictionary<WebContentFormat, IClientMessageFormatter>();
     foreach (WebContentFormat key in formatters.Keys)
     {
         this.formatters.Add(key, formatters[key]);
     }
     this.defaultFormatter = defaultFormatter;
 }
 public ContentTypeSettingClientMessageFormatter(string outgoingContentType, IClientMessageFormatter innerFormatter)
 {
     if (outgoingContentType == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("outgoingContentType");
     }
     if (innerFormatter == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("innerFormatter");
     }
     this.outgoingContentType = outgoingContentType;
     this.innerFormatter = innerFormatter;
 }
    public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
    {
        var serializerBehavior = operationDescription.Behaviors.Find <XmlSerializerOperationBehavior>();

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

        IClientMessageFormatter innerClientFormatter = clientOperation.Formatter;

        clientOperation.Formatter = new RoyalMailMessageFormatter(innerClientFormatter);
    }
 public DemultiplexingClientMessageFormatter(IDictionary <WebContentFormat, IClientMessageFormatter> formatters, IClientMessageFormatter defaultFormatter)
 {
     if (formatters == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("formatters");
     }
     this.formatters = new Dictionary <WebContentFormat, IClientMessageFormatter>();
     foreach (WebContentFormat key in formatters.Keys)
     {
         this.formatters.Add(key, formatters[key]);
     }
     this.defaultFormatter = defaultFormatter;
 }
        internal ProxyOperationRuntime(ClientOperation operation, ImmutableClientRuntime parent)
        {
            if (operation == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
            if (parent == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");

            this.parent = parent;
            this.formatter = operation.Formatter;
            this.isInitiating = operation.IsInitiating;
            this.isOneWay = operation.IsOneWay;
            this.isTerminating = operation.IsTerminating;
            this.isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled;
            this.name = operation.Name;
            this.parameterInspectors = EmptyArray<IParameterInspector>.ToArray(operation.ParameterInspectors);
            this.faultFormatter = operation.FaultFormatter;
            this.serializeRequest = operation.SerializeRequest;
            this.deserializeReply = operation.DeserializeReply;
            this.action = operation.Action;
            this.replyAction = operation.ReplyAction;
            this.beginMethod = operation.BeginMethod;
            this.syncMethod = operation.SyncMethod;
            this.taskMethod = operation.TaskMethod;
            this.TaskTResult = operation.TaskTResult;

            if (this.beginMethod != null)
            {
                this.inParams = ServiceReflector.GetInputParameters(this.beginMethod, true);
                if (this.syncMethod != null)
                {
                    this.outParams = ServiceReflector.GetOutputParameters(this.syncMethod, false);
                }
                else
                {
                    this.outParams = NoParams;
                }
                this.endOutParams = ServiceReflector.GetOutputParameters(operation.EndMethod, true);
                this.returnParam = operation.EndMethod.ReturnParameter;
            }
            else if (this.syncMethod != null)
            {
                this.inParams = ServiceReflector.GetInputParameters(this.syncMethod, false);
                this.outParams = ServiceReflector.GetOutputParameters(this.syncMethod, false);
                this.returnParam = this.syncMethod.ReturnParameter;
            }

            if (this.formatter == null && (serializeRequest || deserializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ClientRuntimeRequiresFormatter0, this.name)));
            }
        }
Пример #15
0
        internal ProxyOperationRuntime(ClientOperation operation, ImmutableClientRuntime parent)
        {
            if (operation == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
            if (parent == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");

            _parent = parent;
            _formatter = operation.Formatter;
            _isInitiating = operation.IsInitiating;
            _isOneWay = operation.IsOneWay;
            _isTerminating = operation.IsTerminating;
            _isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled;
            _name = operation.Name;
            _parameterInspectors = EmptyArray<IParameterInspector>.ToArray(operation.ParameterInspectors);
            _faultFormatter = operation.FaultFormatter;
            _serializeRequest = operation.SerializeRequest;
            _deserializeReply = operation.DeserializeReply;
            _action = operation.Action;
            _replyAction = operation.ReplyAction;
            _beginMethod = operation.BeginMethod;
            _syncMethod = operation.SyncMethod;
            _taskMethod = operation.TaskMethod;
            this.TaskTResult = operation.TaskTResult;

            if (_beginMethod != null)
            {
                _inParams = ServiceReflector.GetInputParameters(_beginMethod, true);
                if (_syncMethod != null)
                {
                    _outParams = ServiceReflector.GetOutputParameters(_syncMethod, false);
                }
                else
                {
                    _outParams = Array.Empty<ParameterInfo>();
                }
                _endOutParams = ServiceReflector.GetOutputParameters(operation.EndMethod, true);
                _returnParam = operation.EndMethod.ReturnParameter;
            }
            else if (_syncMethod != null)
            {
                _inParams = ServiceReflector.GetInputParameters(_syncMethod, false);
                _outParams = ServiceReflector.GetOutputParameters(_syncMethod, false);
                _returnParam = _syncMethod.ReturnParameter;
            }

            if (_formatter == null && (_serializeRequest || _deserializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.ClientRuntimeRequiresFormatter0, _name)));
            }
        }
Пример #16
0
        public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
        {
            Console.WriteLine("{0}: ", clientOperation.Name);
            IClientMessageFormatter formatter = clientOperation.Formatter;

            Console.WriteLine("\t{0}", formatter.GetType().Name);
            if (formatter.GetType().Name != "CompositeClientFormatter")
            {
                return;
            }

            object innerFormatter = this.GetField(formatter, "request");

            Console.WriteLine("\t\t{0}", innerFormatter.GetType().Name);
        }
        public static IClientMessageFormatter CreateXmlAndJsonClientFormatter(OperationDescription operation, Type type, bool isRequestFormatter, UnwrappedTypesXmlSerializerManager xmlSerializerManager)
        {
            IClientMessageFormatter xmlFormatter = CreateClientFormatter(operation, type, isRequestFormatter, false, xmlSerializerManager);

            if (!WebHttpBehavior.SupportsJsonFormat(operation))
            {
                return(xmlFormatter);
            }
            IClientMessageFormatter jsonFormatter = CreateClientFormatter(operation, type, isRequestFormatter, true, xmlSerializerManager);
            Dictionary <WebContentFormat, IClientMessageFormatter> map = new Dictionary <WebContentFormat, IClientMessageFormatter>();

            map.Add(WebContentFormat.Xml, xmlFormatter);
            map.Add(WebContentFormat.Json, jsonFormatter);
            return(new DemultiplexingClientMessageFormatter(map, xmlFormatter));
        }
Пример #18
0
        public T CreateChannel()
        {
            MessageEncoderFactory encoder = ComponentBuilder.GetMessageEncoderFactory();
            ChannelProxy <T>      proxy   = new ChannelProxy <T>(this.Address, MessageVersion.Default, encoder);

            ContractDescription cd = ContractDescription.GetContract(typeof(T));

            foreach (var item in cd.Operations)
            {
                IClientMessageFormatter messageFormatter = (IClientMessageFormatter)ComponentBuilder.GetMessageFormatter(item, true);
                proxy.MessageFormatter.Add(item.Name, messageFormatter);
            }

            return((T)proxy.GetTransparentProxy());
        }
 public UriTemplateClientFormatter(OperationDescription operationDescription, IClientMessageFormatter inner, QueryStringConverter qsc, Uri baseUri, bool innerIsUntypedMessage, string contractName)
 {
     this.inner   = inner;
     this.qsc     = qsc;
     this.baseUri = baseUri;
     this.innerIsUntypedMessage = innerIsUntypedMessage;
     Populate(out this.pathMapping,
              out this.queryMapping,
              out this.totalNumUTVars,
              out this.uriTemplate,
              operationDescription,
              qsc,
              contractName);
     this.method = WebHttpBehavior.GetWebMethod(operationDescription);
     isGet       = this.method == WebHttpBehavior.GET;
 }
 public UriTemplateClientFormatter(OperationDescription operationDescription, IClientMessageFormatter inner, QueryStringConverter qsc, Uri baseUri, bool innerIsUntypedMessage, string contractName)
 {
     this.inner = inner;
     this.qsc = qsc;
     this.baseUri = baseUri;
     this.innerIsUntypedMessage = innerIsUntypedMessage;
     Populate(out this.pathMapping,
         out this.queryMapping,
         out this.totalNumUTVars,
         out this.uriTemplate,
         operationDescription,
         qsc,
         contractName);
     this.method = WebHttpBehavior.GetWebMethod(operationDescription);
     isGet = this.method == WebHttpBehavior.GET;
 }
        /// <summary>
        /// </summary>
        /// <param name="operationDescription"></param>
        /// <param name="endpoint"></param>
        /// <returns></returns>
        protected override IClientMessageFormatter GetRequestClientFormatter(OperationDescription operationDescription, ServiceEndpoint endpoint)
        {
            IClientMessageFormatter formatter = null;

            //formatter = base.GetRequestClientFormatter(operationDescription, endpoint);
            if (this.IsGetOperation(operationDescription))
            {
                var flags  = BindingFlags.CreateInstance | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.InvokeMethod;
                var method = typeof(WebHttpBehavior).GetMethod("GetRequestClientFormatter", flags);
                return(method.Invoke(this.basicImplementor, new object[] { operationDescription, endpoint }) as IClientMessageFormatter);
            }
            else
            {
                formatter = new MissingClientMessageFormatter();
            }
            return(formatter);
        }
Пример #22
0
        /// <summary>
        /// for client
        /// </summary>
        /// <param name="operationName"></param>
        /// <param name="parameterInfos"></param>
        /// <param name="innerClientFormatter"></param>
        /// <param name="action"></param>
        public BinaryFormatterAdapter(
            string operationName,
            ParameterInfo[] parameterInfos,
            IClientMessageFormatter innerClientFormatter,
            string action
            )
        {
            if (operationName == null) throw new ArgumentNullException("methodName");
            if (parameterInfos == null) throw new ArgumentNullException("parameterInfos");
            if (innerClientFormatter == null) throw new ArgumentNullException("innerClientFormatter");
            if (action == null) throw new ArgumentNullException("action");

            this._innerClientFormatter = innerClientFormatter;
            this._parameterInfos = parameterInfos;
            this._operationName = operationName;
            this._action = action;
        }
Пример #23
0
        public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
        {
            Console.WriteLine("{0}: ", clientOperation.Name);
            IClientMessageFormatter formatter = clientOperation.Formatter;

            Console.WriteLine("\t{0}", formatter.GetType().Name);

            if (formatter.GetType().Name != "CompositeClientFormatter")
            {
                return;
            }
            object innerFormatter = this.GetField(formatter, "reply");

            Console.WriteLine("\t\t{0}", innerFormatter.GetType().Name);

            if (innerFormatter.GetType().Name == "DemultiplexingClientMessageFormatter")
            {
                Dictionary <WebContentFormat, IClientMessageFormatter> formatters = this.GetField(innerFormatter, "formatters") as Dictionary <WebContentFormat, IClientMessageFormatter>;
                Console.WriteLine("\t\t\t{0, -4}: {1}", "Xml", formatters[WebContentFormat.Xml].GetType().Name);
                Console.WriteLine("\t\t\t{0, -4}: {1}", "Json", formatters[WebContentFormat.Json].GetType().Name);
            }
        }
Пример #24
0
        public void RequestClientFormatter2()
        {
            var se = CreateEndpoint();
            var od = se.Contract.Operations [0];
            var b  = new WebHttpBehaviorExt();
            IClientMessageFormatter rcf = null;

            b.ApplyClientBehaviorInvoked += delegate(ServiceEndpoint e, ClientRuntime cr) {
                rcf = cr.Operations [0].Formatter;
            };
            se.Behaviors.Add(b);
            var ch  = new WebChannelFactory <IMyServiceClient> (se).CreateChannel();
            var msg = rcf.SerializeRequest(MessageVersion.None, new object [] { "foo" });
            var hp  = msg.Properties [HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;

            Assert.IsNotNull(hp, "#1");
            Assert.IsTrue(msg.IsEmpty, "#2");
            Assert.AreEqual(String.Empty, hp.QueryString, "#3");
            //var mb = msg.CreateBufferedCopy (1000);

            // TODO: test DeserializeReply too (it is supported unlike above).
        }
Пример #25
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>
        /// 获取Client端处理请求的格式化器
        /// </summary>
        /// <param name="operationDescription"></param>
        /// <param name="endpoint"></param>
        /// <returns></returns>
        protected override IClientMessageFormatter GetRequestClientFormatter(OperationDescription operationDescription, ServiceEndpoint endpoint)
        {
            IClientMessageFormatter formatter = null;

            if (this.IsWebGetOperation(operationDescription))
            {
                formatter = base.GetRequestClientFormatter(operationDescription, endpoint);
            }
            else
            {
                // 沈峥注释,2015/3/19,去掉无参的请求调用默认Formatter
                //if (IsOperationHasParams(operationDescription) == false)
                //{
                //    formatter = base.GetRequestClientFormatter(operationDescription, endpoint);
                //}
                //else
                //{
                //    formatter = new WfJsonClientFormatter(operationDescription, endpoint);
                //}
                formatter = new WfJsonClientFormatter(operationDescription, endpoint);
            }

            return(formatter);
        }
Пример #27
0
        public QueryStringFormatter(string operationName, ParameterInfo[] parameterInfos, IClientMessageFormatter innerClientFormatter, string action, EndpointAddress address)
        {
            if (operationName == null)
                throw new ArgumentNullException("methodName");

            if (parameterInfos == null)
                throw new ArgumentNullException("parameterInfos");

            if (innerClientFormatter == null)
                throw new ArgumentNullException("innerClientFormatter");

            if (action == null)
                throw new ArgumentNullException("action");

            if (address == null)
                throw new ArgumentNullException("address");

            QueryStringFormatter.ValidateSupportedType(parameterInfos);
            this.innerClientFormatter = innerClientFormatter;
            this.parameterInfos = parameterInfos;
            this.operationName = operationName;
            this.action = action;
            this.address = address;
        }
Пример #28
0
 public ServiceBusFormatter(IClientMessageFormatter originalFormatter)
 {
     this.originalFormatter = originalFormatter;
 }
Пример #29
0
    public void ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
    {
        IClientMessageFormatter currentFormatter = proxy.Formatter;

        proxy.Formatter = new RoyalMailMessageFormatter(currentFormatter);
    }
Пример #30
0
 public AppendSuffixToStringFormatter(IClientMessageFormatter inner, string suffix)
 {
     _inner  = inner;
     _suffix = suffix;
 }
Пример #31
0
 internal void SetFormatter(IClientMessageFormatter formatter)
 {
     if (this.requestFormatter != null)
     {
         this.requestFormatter.Formatter = formatter;
     }
     else
     {
         // we save the formatter and set the requestFormatter.Formatter later
         this.lazyFormatter = formatter;
     }
 }
 public JsonClientFormatter(IClientMessageFormatter clientMessageFormatter, OperationDescription operationDescription, Type _resultType)
 {
     this._actual = clientMessageFormatter;
     this._operationDescription = operationDescription;
     this._resultType = _resultType;
 }
		public DefaultTypedMessageConverter (IClientMessageFormatter formatter)
		{
			this.formatter = formatter;
		}
Пример #34
0
 public PoxFormatter(MessageDescription responseDescription, IClientMessageFormatter formatter)
 {
     _responseDescription = responseDescription;
     _formatter = formatter;
 }
 public CompositeClientFormatter(IClientMessageFormatter request, IClientMessageFormatter reply)
 {
     this.request = request;
     this.reply = reply;
 }
Пример #36
0
 public DefaultTypedMessageConverter(IClientMessageFormatter formatter)
 {
     this.formatter = formatter;
 }
Пример #37
0
 internal FileUploadSerializer(IClientMessageFormatter originalFormatter)
 {
     this.originalFormatter = originalFormatter;
 }
 public CustomMessageFormatter(IClientMessageFormatter innerClientFormatter)
 {
     InnerClientFormatter = innerClientFormatter;
 }
Пример #39
0
 public GetOrdersMessageFormatter(IClientMessageFormatter actual)
 {
     original = actual;
 }
Пример #40
0
 public MyClientFormatter(IClientMessageFormatter inner)
 {
     if (inner == null) throw new ArgumentNullException("inner");
     this.inner = inner;
 }
 public RoyalMailMessageFormatter(IClientMessageFormatter formatter)
 {
     this.formatter = formatter;
 }
 internal void SetFormatter(IClientMessageFormatter formatter)
 {
     if (this.requestFormatter != null)
     {
         this.requestFormatter.Formatter = formatter;
     }
     else
     {
         this.lazyFormatter = formatter;
     }
 }
 public CollectionIsListMessageFormatter(IClientMessageFormatter defaultFormatter)
 {
     _defaultFormatter = defaultFormatter;
 }
 public MyClientMessageFormatter(IClientMessageFormatter inner)
 {
     this.inner = inner;
 }
Пример #45
0
 internal WeaklyTypedJsonDeserializer(IClientMessageFormatter originalFormatter, Type returnType)
 {
     this.originalFormatter = originalFormatter;
     this.returnType = returnType;
 }
Пример #46
0
 public JsonOrXmlReplyFormatter(IClientMessageFormatter xmlFormatter, IClientMessageFormatter jsonFormatter)
 {
     this.xmlFormatter  = xmlFormatter;
     this.jsonFormatter = jsonFormatter;
 }
Пример #47
0
        protected override void CacheMetadata(ActivityMetadata metadata)
        {
            if (this.Request == null)
            {
                metadata.AddValidationError(SR.ReceiveReplyRequestCannotBeNull(this.DisplayName));
            }
            else
            {
                // Need to validate Send.ServiceContractName and Send.OperationName here so that we can proceed with contract inference
                if (this.Request.ServiceContractName == null)
                {
                    string errorOperationName = ContractValidationHelper.GetErrorMessageOperationName(this.Request.OperationName);
                    metadata.AddValidationError(SR.MissingServiceContractName(this.Request.DisplayName, errorOperationName));
                }
                if (string.IsNullOrEmpty(this.Request.OperationName))
                {
                    metadata.AddValidationError(SR.MissingOperationName(this.Request.DisplayName));
                }
            }

            // validate Correlation Initializers
            MessagingActivityHelper.ValidateCorrelationInitializer(metadata, this.correlationInitializers, true, this.DisplayName, (this.Request != null ? this.Request.OperationName : String.Empty));

            // Validate Content
            string operationName = this.Request != null ? this.Request.OperationName : null;

            this.InternalContent.CacheMetadata(metadata, this, operationName);

            if (this.correlationInitializers != null)
            {
                for (int i = 0; i < this.correlationInitializers.Count; i++)
                {
                    CorrelationInitializer initializer = this.correlationInitializers[i];
                    initializer.ArgumentName = Constants.Parameter + i;
                    RuntimeArgument initializerArgument = new RuntimeArgument(initializer.ArgumentName, Constants.CorrelationHandleType, ArgumentDirection.In);
                    metadata.Bind(initializer.CorrelationHandle, initializerArgument);
                    metadata.AddArgument(initializerArgument);
                }
            }

            if (!metadata.HasViolations)
            {
                this.internalReceive = CreateInternalReceive();

                InArgument <CorrelationHandle> requestReplyHandleFromSend = GetReplyHandleFromSend();
                if (requestReplyHandleFromSend != null)
                {
                    InArgument <CorrelationHandle> resultCorrelatesWith = MessagingActivityHelper.CreateReplyCorrelatesWith(requestReplyHandleFromSend);

                    RuntimeArgument resultCorrelatesWithArgument = new RuntimeArgument("ResultCorrelatesWith", Constants.CorrelationHandleType, ArgumentDirection.In);
                    metadata.Bind(resultCorrelatesWith, resultCorrelatesWithArgument);
                    metadata.AddArgument(resultCorrelatesWithArgument);

                    this.internalReceive.CorrelatesWith = (InArgument <CorrelationHandle>)InArgument.CreateReference(resultCorrelatesWith, "ResultCorrelatesWith");
                }

                this.InternalContent.ConfigureInternalReceiveReply(this.internalReceive, out this.responseFormatter);

                if (this.InternalContent is ReceiveMessageContent &&
                    MessageBuilder.IsMessageContract(((ReceiveMessageContent)this.InternalContent).InternalDeclaredMessageType))
                {
                    this.Request.OperationUsesMessageContract = true;
                }

                OperationDescription operation = ContractInferenceHelper.CreateTwoWayOperationDescription(this.Request, this);
                this.Request.OperationDescription = operation;

                if (this.responseFormatter != null)
                {
                    IClientMessageFormatter formatter = ClientOperationFormatterProvider.GetFormatterFromRuntime(operation);

                    this.Request.SetFormatter(formatter);
                    this.responseFormatter.Formatter = formatter;

                    //
                    int    index      = 0;
                    Type[] faultTypes = new Type[operation.KnownTypes.Count];
                    foreach (Type type in operation.KnownTypes)
                    {
                        faultTypes[index] = type;
                        index++;
                    }

                    this.responseFormatter.FaultFormatter = new FaultFormatter(faultTypes);
                }

                // Add CorrelationQuery to the Send->ReplyCorrelation, we validate that the same query is not added multiple times
                if (this.correlationInitializers != null && this.correlationInitializers.Count > 0)
                {
                    Collection <CorrelationQuery> internalCorrelationQueryCollection = ContractInferenceHelper.CreateClientCorrelationQueries(null, this.correlationInitializers,
                                                                                                                                              this.Action, this.Request.ServiceContractName, this.Request.OperationName, true);

                    foreach (CorrelationQuery query in internalCorrelationQueryCollection)
                    {
                        this.Request.SetReplyCorrelationQuery(query);
                    }
                }
            }
            else
            {
                this.internalReceive   = null;
                this.responseFormatter = null;
            }

            // We don't have any imported children despite referencing the Request
            metadata.SetImportedChildrenCollection(new Collection <Activity>());
        }
Пример #48
0
 /// <summary>
 /// Initializes a new instance of the SecurityTokenExtractor class.
 /// </summary>
 /// <param name="originalFormatter">The original message formatter that should be decorated</param>
 /// <param name="tokenXPath">The XPath expression used to extract the security token from xml</param>
 internal SecurityTokenExtractor(IClientMessageFormatter originalFormatter, string tokenXPath)
 {
     this.originalFormatter = originalFormatter;
     this.tokenXPath = tokenXPath;
 }
Пример #49
0
 public Base64BodyFormatter(IClientMessageFormatter ora_Formatter)
 {
     this.clientFormatter = ora_Formatter;
 }
Пример #50
0
 public MyClientMessageFormatter(IClientMessageFormatter inner)
 {
     this.inner = inner;
 }
Пример #51
0
 public Base64BodyFormatter(IClientMessageFormatter ora_Formatter)
 {
     this.clientFormatter = ora_Formatter;
 }
Пример #52
0
 public ClientPairFormatter(IClientMessageFormatter request, IClientMessageFormatter reply)
 {
     this.request = request;
     this.reply   = reply;
 }
Пример #53
0
 public CompressionMessageFormatter(MessageCompressor messageCompressor,
                                    IDispatchMessageFormatter innerDispatchMessageFormatter, IClientMessageFormatter innerClientMessageFormatter)
 {
     this.MessageCompressor             = messageCompressor;
     this.InnerDispatchMessageFormatter = innerDispatchMessageFormatter;
     this.InnerClientMessageFormatter   = innerClientMessageFormatter;
 }
Пример #54
0
			public ClientPairFormatter (IClientMessageFormatter request, IClientMessageFormatter reply)
			{
				this.request = request;
				this.reply = reply;
			}
 public TraceMessageSizeFormatter(
     ClientOperation clientOperation)
 {
     this.clientOperation = clientOperation;
     this.clientFormatter = clientOperation.Formatter;                
 }
Пример #56
0
 public AppendSuffixToStringFormatter(IClientMessageFormatter inner, string suffix)
 {
     _inner = inner;
     _suffix = suffix;
 }