예제 #1
0
        private object[] MapOutputs(ParameterInfo[] parameters, MethodCall methodCall, object[] outs, ref object ret)
        {
            if (ret == null && _returnParam != null)
            {
                ret = GetDefaultParameterValue(TypeLoader.GetParameterType(_returnParam));
            }

            if (parameters.Length == 0)
            {
                return(null);
            }

            object[] args = methodCall.Args;
            for (int i = 0; i < parameters.Length; i++)
            {
                if (outs[i] == null)
                {
                    // the RealProxy infrastructure requires a default value for value types
                    args[parameters[i].Position] = GetDefaultParameterValue(TypeLoader.GetParameterType(parameters[i]));
                }
                else
                {
                    args[parameters[i].Position] = outs[i];
                }
            }

            return(args);
        }
 void DeclareParameterLocals(ParameterInfo[] parameters, LocalBuilder[] parameterLocals)
 {
     for (int i = 0; i < parameterLocals.Length; i++)
     {
         parameterLocals[i] = ilg.DeclareLocal(TypeLoader.GetParameterType(parameters[i]), "param" + i.ToString(CultureInfo.InvariantCulture));
     }
 }
예제 #3
0
        private MessageDescription CreateParameterMessageDescription(ContractDescription contract, ParameterInfo[] parameters, Type returnType, ICustomAttributeProvider returnCustomAttributes, System.ServiceModel.Description.XmlName returnValueName, string methodName, string ns, string action, MessageDirection direction, bool allowReferences)
        {
            MessageDescription description = new MessageDescription(action, direction)
            {
                Body = { WrapperNamespace = ns }
            };

            for (int i = 0; i < parameters.Length; i++)
            {
                ParameterInfo parameterInfo = parameters[i];
                Type          parameterType = TypeLoader.GetParameterType(parameterInfo);
                if (!ComPlusTypeValidator.IsValidParameter(parameterType, parameterInfo, allowReferences))
                {
                    throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidWebServiceParameter", new object[] { parameterInfo.Name, parameterType.Name, methodName, contract.Name })));
                }
                MessagePartDescription item = this.CreateMessagePartDescription(parameterType, new System.ServiceModel.Description.XmlName(parameterInfo.Name), ns, i);
                description.Body.Parts.Add(item);
            }
            System.ServiceModel.Description.XmlName operationName = new System.ServiceModel.Description.XmlName(methodName);
            if (returnType == null)
            {
                description.Body.WrapperName = operationName.EncodedName;
                return(description);
            }
            description.Body.WrapperName = TypeLoader.GetBodyWrapperResponseName(operationName).EncodedName;
            if (!ComPlusTypeValidator.IsValidParameter(returnType, returnCustomAttributes, allowReferences))
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidWebServiceReturnValue", new object[] { returnType.Name, methodName, contract.Name })));
            }
            MessagePartDescription description3 = this.CreateMessagePartDescription(returnType, returnValueName, ns, 0);

            description.Body.ReturnValue = description3;
            return(description);
        }
 private object[] MapOutputs(ParameterInfo[] parameters, IMethodCallMessage methodCall, object[] outs, ref object ret)
 {
     if ((ret == null) && (this.returnParam != null))
     {
         ret = GetDefaultParameterValue(TypeLoader.GetParameterType(this.returnParam));
     }
     if (parameters.Length == 0)
     {
         return(null);
     }
     object[] args = methodCall.Args;
     for (int i = 0; i < parameters.Length; i++)
     {
         if (outs[i] == null)
         {
             args[parameters[i].Position] = GetDefaultParameterValue(TypeLoader.GetParameterType(parameters[i]));
         }
         else
         {
             args[parameters[i].Position] = outs[i];
         }
     }
     return(args);
 }
예제 #5
0
        MessageDescription CreateParameterMessageDescription(ContractDescription contract,
                                                             ParameterInfo[] parameters,
                                                             Type returnType,
                                                             ICustomAttributeProvider returnCustomAttributes,
                                                             XmlName returnValueName,
                                                             string methodName,
                                                             string ns,
                                                             string action,
                                                             MessageDirection direction,
                                                             bool allowReferences)
        {
            MessageDescription messageDescription = new MessageDescription(action, direction);

            messageDescription.Body.WrapperNamespace = ns;

            for (int index = 0; index < parameters.Length; index++)
            {
                ParameterInfo parameter     = parameters[index];
                Type          parameterType = TypeLoader.GetParameterType(parameter);

                if (!ComPlusTypeValidator.IsValidParameter(parameterType, parameter, allowReferences))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(SR.GetString(SR.InvalidWebServiceParameter,
                                                                                                                    parameter.Name,
                                                                                                                    parameterType.Name,
                                                                                                                    methodName,
                                                                                                                    contract.Name)));
                }

                MessagePartDescription messagePart = CreateMessagePartDescription(parameterType,
                                                                                  new XmlName(parameter.Name),
                                                                                  ns,
                                                                                  index);
                messageDescription.Body.Parts.Add(messagePart);
            }

            XmlName xmlName = new XmlName(methodName);

            if (returnType == null)
            {
                messageDescription.Body.WrapperName = xmlName.EncodedName;
            }
            else
            {
                messageDescription.Body.WrapperName = TypeLoader.GetBodyWrapperResponseName(xmlName).EncodedName;

                if (!ComPlusTypeValidator.IsValidParameter(returnType, returnCustomAttributes, allowReferences))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(SR.GetString(SR.InvalidWebServiceReturnValue,
                                                                                                                    returnType.Name,
                                                                                                                    methodName,
                                                                                                                    contract.Name)));
                }

                MessagePartDescription messagePart = CreateMessagePartDescription(returnType,
                                                                                  returnValueName,
                                                                                  ns,
                                                                                  0);
                messageDescription.Body.ReturnValue = messagePart;
            }

            return(messageDescription);
        }