Exemple #1
0
        protected override void Execute(CodeActivityContext context)
        {
            Message inMessage = this.Message.Get(context);

            if (inMessage == null)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.NullReplyMessageContractMismatch));
            }
            if (inMessage.IsFault)
            {
                FaultConverter faultConverter = FaultConverter.GetDefaultFaultConverter(inMessage.Version);
                Exception      exception      = DeserializeFault(inMessage, faultConverter);

                // We simply throw the exception
                throw FxTrace.Exception.AsError(exception);
            }
            else
            {
                object[] outObjects;
                if (this.parameters != null)
                {
                    outObjects = new object[this.parameters.Count];
                }
                else
                {
                    outObjects = Constants.EmptyArray;
                }

                object returnValue = this.Formatter.DeserializeReply(inMessage, outObjects);

                if (this.Result != null)
                {
                    this.Result.Set(context, returnValue);
                }

                if (parameters != null)
                {
                    for (int i = 0; i < this.parameters.Count; i++)
                    {
                        OutArgument outArgument = this.parameters[i];
                        Fx.Assert(outArgument != null, "Parameter cannot be null");

                        object obj = outObjects[i];
                        if (obj == null)
                        {
                            obj = ProxyOperationRuntime.GetDefaultParameterValue(outArgument.ArgumentType);
                        }

                        outArgument.Set(context, obj);
                    }
                }
            }
        }
Exemple #2
0
 protected override void Execute(NativeActivityContext context)
 {
     System.ServiceModel.Channels.Message message = null;
     try
     {
         object[] emptyArray;
         message = this.Message.Get(context);
         if ((this.parameters == null) || (this.parameters.Count == 0))
         {
             emptyArray = System.ServiceModel.Activities.Constants.EmptyArray;
         }
         else
         {
             emptyArray = new object[this.parameters.Count];
         }
         this.Formatter.DeserializeRequest(message, emptyArray);
         if (this.parameters != null)
         {
             for (int i = 0; i < this.parameters.Count; i++)
             {
                 OutArgument argument = this.parameters[i];
                 object      defaultParameterValue = emptyArray[i];
                 if (defaultParameterValue == null)
                 {
                     defaultParameterValue = ProxyOperationRuntime.GetDefaultParameterValue(argument.ArgumentType);
                 }
                 argument.Set(context, defaultParameterValue);
             }
         }
     }
     finally
     {
         if (this.CloseMessage && (message != null))
         {
             message.Close();
         }
         this.Message.Set(context, null);
         System.Activities.NoPersistHandle handle = (this.NoPersistHandle == null) ? null : this.NoPersistHandle.Get(context);
         if (handle != null)
         {
             handle.Exit(context);
         }
     }
 }
        protected override void Execute(CodeActivityContext context)
        {
            object[] emptyArray;
            System.ServiceModel.Channels.Message inMessage = this.Message.Get(context);
            if (inMessage == null)
            {
                throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.NullReplyMessageContractMismatch));
            }
            if (inMessage.IsFault)
            {
                FaultConverter defaultFaultConverter = FaultConverter.GetDefaultFaultConverter(inMessage.Version);
                Exception      exception             = this.DeserializeFault(inMessage, defaultFaultConverter);
                throw System.ServiceModel.Activities.FxTrace.Exception.AsError(exception);
            }
            if (this.parameters != null)
            {
                emptyArray = new object[this.parameters.Count];
            }
            else
            {
                emptyArray = System.ServiceModel.Activities.Constants.EmptyArray;
            }
            object obj2 = this.Formatter.DeserializeReply(inMessage, emptyArray);

            if (this.Result != null)
            {
                this.Result.Set(context, obj2);
            }
            if (this.parameters != null)
            {
                for (int i = 0; i < this.parameters.Count; i++)
                {
                    OutArgument argument = this.parameters[i];
                    object      defaultParameterValue = emptyArray[i];
                    if (defaultParameterValue == null)
                    {
                        defaultParameterValue = ProxyOperationRuntime.GetDefaultParameterValue(argument.ArgumentType);
                    }
                    argument.Set(context, defaultParameterValue);
                }
            }
        }
        protected override void Execute(NativeActivityContext context)
        {
            Message inMessage = null;

            try
            {
                inMessage = this.Message.Get(context);
                object[] outObjects;
                if (this.parameters == null || this.parameters.Count == 0)
                {
                    outObjects = Constants.EmptyArray;
                }
                else
                {
                    outObjects = new object[this.parameters.Count];
                }

                // The formatter would be null if there is no parameters to Deserialize in message contracts
                if (this.Formatter != null)
                {
                    this.Formatter.DeserializeRequest(inMessage, outObjects);
                }
                else
                {
                    Fx.Assert(this.parameters == null, "There shouldn't be any parameters to be deserialized");
                }

                if (this.parameters != null)
                {
                    for (int i = 0; i < this.parameters.Count; i++)
                    {
                        OutArgument outArgument = this.parameters[i];
                        Fx.Assert(outArgument != null, "Parameter cannot be null");

                        object obj = outObjects[i];
                        if (obj == null)
                        {
                            obj = ProxyOperationRuntime.GetDefaultParameterValue(outArgument.ArgumentType);
                        }

                        outArgument.Set(context, obj);
                    }
                }
            }
            finally
            {
                if (this.CloseMessage && inMessage != null)
                {
                    inMessage.Close();
                }

                this.Message.Set(context, null);

                bool useNoPersistHandle = UseNoPersistHandle(context);
                if (useNoPersistHandle)
                {
                    NoPersistHandle handle = (this.NoPersistHandle == null) ? null : this.NoPersistHandle.Get(context);
                    if (handle != null)
                    {
                        handle.Exit(context);
                    }
                }
            }
        }