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)));
            }
        }
Exemple #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)));
            }
        }
 MessageDescription CreateOutgoingMessageDescription(ContractDescription contract,
                                                     MethodInfo methodInfo,
                                                     XmlName returnValueName,
                                                     string ns,
                                                     string action,
                                                     bool allowReferences)
 {
     ParameterInfo[] parameters = ServiceReflector.GetOutputParameters(methodInfo, false);
     return(CreateParameterMessageDescription(contract,
                                              parameters,
                                              methodInfo.ReturnType,
                                              methodInfo.ReturnTypeCustomAttributes,
                                              returnValueName,
                                              methodInfo.Name,
                                              ns,
                                              action,
                                              MessageDirection.Output,
                                              allowReferences));
 }