Exemplo n.º 1
0
 // Apply Context to a SendActivity
 static public void ApplyContext(SendActivity activity, IDictionary<string, string> context)
 {
     if (activity.ExecutionStatus == ActivityExecutionStatus.Initialized)
     {
         activity.Context = context;
     }
 }
Exemplo n.º 2
0
        void Container17()
        {
            //SendActivity.SendActivity(String)
            //<snippet17>
            SendActivity RequestQuoteFromShipper3;

            RequestQuoteFromShipper3 = new System.Workflow.Activities.SendActivity("RequestQuoteFromShipper3");
            //</snippet17>
        }
Exemplo n.º 3
0
        void Container16()
        {
            //SendActivity.SendActivity()
            //<snippet16>
            SendActivity RequestQuoteFromShipper3;

            RequestQuoteFromShipper3 = new System.Workflow.Activities.SendActivity();
            //</snippet16>
        }
Exemplo n.º 4
0
 // Apply EndpointAddress to a SendActivity
 static public void ApplyEndpointAddress(SendActivity activity, EndpointAddress epr)
 {
     if (activity.ExecutionStatus == ActivityExecutionStatus.Initialized)
     {
         if (epr.Uri != null)
         {
             activity.CustomAddress = epr.Uri.ToString();
         }
         if (epr.Headers != null && epr.Headers.Count > 0)
         {
             AddressHeader contextHeader = epr.Headers.FindHeader(contextHeaderName, contextHeaderNamespace);
             IDictionary<string, string> context = contextHeader.GetValue<Dictionary<string, string>>();                    
             activity.Context = context;
         }
     }
 }
Exemplo n.º 5
0
            public void PopulateOutputs(SendActivity activity, WorkflowParameterBindingCollection bindings, object[] outputs, object returnValue)
            {
                if (activity == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
                }

                if (outputs == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("outputs");
                }

                if (this.outputParameters.Count > 0 && outputs.Length > 0)
                {
                    for (int index = 0; index < outputParameters.Count; ++index)
                    {
                        KeyValuePair <int, string> parameterInfo = outputParameters[index];
                        if (bindings.Contains(parameterInfo.Value))
                        {
                            bindings[parameterInfo.Value].Value = outputs[parameterInfo.Key];
                        }
                        else
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                      new InvalidOperationException(SR2.GetString(SR2.Error_ParameterBindingMissing,
                                                                                  parameterInfo.Value, this.operationName, activity.Name)));
                        }
                    }
                }

                if (hasReturnValue)
                {
                    if (bindings.Contains(SendActivity.ReturnValuePropertyName))
                    {
                        bindings[SendActivity.ReturnValuePropertyName].Value = returnValue;
                    }
                    else
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                  new InvalidOperationException(SR2.GetString(SR2.Error_ParameterBindingMissing,
                                                                              SendActivity.ReturnValuePropertyName,
                                                                              this.operationName,
                                                                              activity.Name)));
                    }
                }
            }
Exemplo n.º 6
0
        protected override void InitializeProperties()
        {
            TypedOperationInfo serviceOperationInfo = this.ServiceOperationInfo;

            if (serviceOperationInfo == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR2.GetString(SR2.Error_ServiceOperationInfoNotSpecified, this.Name)));
            }

            OperationParameterInfoCollection parameters = null;

            Activity definitionRoot = base.RootActivity.GetValue(Activity.WorkflowDefinitionProperty) as Activity;

            if (definitionRoot != null)
            {
                SendActivity definition = definitionRoot.GetActivityByName(this.QualifiedName, true) as SendActivity;
                if ((definition != null) && definition.UserData.Contains(typeof(OperationParameterInfoCollection)))
                {
                    parameters = definition.UserData[typeof(OperationParameterInfoCollection)] as OperationParameterInfoCollection;
                }
            }

            if (parameters == null)
            {
                parameters = serviceOperationInfo.GetParameters(this.Site);
                this.UserData[typeof(OperationParameterInfoCollection)] = parameters;
            }

            WorkflowParameterBindingCollection parameterBindings = this.ParameterBindings;

            foreach (OperationParameterInfo parameterInfo in parameters)
            {
                if (!parameterBindings.Contains(parameterInfo.Name))
                {
                    parameterBindings.Add(new WorkflowParameterBinding(parameterInfo.Name));
                }
            }

            base.InitializeProperties();
        }
#pragma warning disable 56504
        public SendActivityEventArgs(SendActivity sendActivity)
        {
            this.sendActivity = sendActivity;
        }
Exemplo n.º 8
0
 static bool MatchByOperation(SendActivity source, SendActivity target)
 {
     return(ReceiveActivityDesigner.MatchByOperation(source.ServiceOperationInfo, target.ServiceOperationInfo));
 }
Exemplo n.º 9
0
            public void PopulateOutputs(SendActivity activity, WorkflowParameterBindingCollection bindings, object[] outputs, object returnValue)
            {
                if (activity == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
                }

                if (outputs == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("outputs");
                }

                if (this.outputParameters.Count > 0 && outputs.Length > 0)
                {
                    for (int index = 0; index < outputParameters.Count; ++index)
                    {
                        KeyValuePair<int, string> parameterInfo = outputParameters[index];
                        if (bindings.Contains(parameterInfo.Value))
                        {
                            bindings[parameterInfo.Value].Value = outputs[parameterInfo.Key];
                        }
                        else
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                new InvalidOperationException(SR2.GetString(SR2.Error_ParameterBindingMissing,
                                parameterInfo.Value, this.operationName, activity.Name)));
                        }
                    }
                }

                if (hasReturnValue)
                {
                    if (bindings.Contains(SendActivity.ReturnValuePropertyName))
                    {
                        bindings[SendActivity.ReturnValuePropertyName].Value = returnValue;
                    }
                    else
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                            new InvalidOperationException(SR2.GetString(SR2.Error_ParameterBindingMissing,
                            SendActivity.ReturnValuePropertyName,
                            this.operationName,
                            activity.Name)));
                    }
                }
            }
Exemplo n.º 10
0
            public object[] GetInputs(SendActivity activity, WorkflowParameterBindingCollection bindings)
            {
                if (activity == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
                }

                object[] inputs = new object[this.parameterCount];

                if (inputParameters.Count > 0)
                {
                    for (int index = 0; index < inputParameters.Count; index++)
                    {
                        KeyValuePair<int, string> parameterInfo = inputParameters[index];

                        if (bindings.Contains(parameterInfo.Value))
                        {
                            inputs[parameterInfo.Key] = bindings[parameterInfo.Value].Value;
                        }
                        else
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                new InvalidOperationException(SR2.GetString(SR2.Error_ParameterBindingMissing,
                                parameterInfo.Value,
                                this.operationName,
                                activity.Name)));
                        }
                    }
                }

                return inputs;
            }
Exemplo n.º 11
0
            public SendOperationInfoHelper(IServiceProvider serviceProvider, SendActivity activity)
            {
                outputParameters = new List<KeyValuePair<int, string>>();
                inputParameters = new List<KeyValuePair<int, string>>();
                hasReturnValue = false;

                if (activity == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
                }

                OperationInfoBase serviceOperationInfo = activity.ServiceOperationInfo;
                if (serviceOperationInfo == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                        new InvalidOperationException(SR2.GetString(SR2.Error_ServiceOperationInfoNotSpecified, activity.Name)));
                }

                MethodInfo methodInfo = serviceOperationInfo.GetMethodInfo(serviceProvider);
                if (methodInfo == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                        new InvalidOperationException(SR2.GetString(SR2.Error_MethodInfoNotAvailable, activity.Name)));
                }

                if (methodInfo.ReturnType != null && methodInfo.ReturnType != typeof(void))
                {
                    hasReturnValue = true;
                }

                foreach (ParameterInfo parameter in methodInfo.GetParameters())
                {
                    if (parameter.ParameterType.IsByRef ||
                        parameter.IsOut || (parameter.IsIn && parameter.IsOut))
                    {
                        outputParameters.Add(new KeyValuePair<int, string>(parameter.Position, parameter.Name));
                    }

                    if (!parameter.IsOut || (parameter.IsIn && parameter.IsOut))
                    {
                        inputParameters.Add(new KeyValuePair<int, string>(parameter.Position, parameter.Name));
                    }
                }

                this.parameterCount = methodInfo.GetParameters().Length;

                this.operationName = serviceOperationInfo.Name;

                object[] operationContractAttribs = methodInfo.GetCustomAttributes(typeof(OperationContractAttribute), true);

                if (operationContractAttribs != null && operationContractAttribs.Length > 0)
                {
                    if (operationContractAttribs[0] is OperationContractAttribute)
                    {
                        this.isOneWay = ((OperationContractAttribute) operationContractAttribs[0]).IsOneWay;
                    }
                }
            }
 static bool MatchByOperation(SendActivity source, SendActivity target)
 {
     return ReceiveActivityDesigner.MatchByOperation(source.ServiceOperationInfo, target.ServiceOperationInfo);
 }
Exemplo n.º 13
0
        public override ValidationErrorCollection Validate(
            ValidationManager manager,
            object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            SendActivity sendActivity = obj as SendActivity;

            if (sendActivity == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("obj",
                                                                             SR2.GetString(SR2.Error_ArgumentTypeInvalid, "obj", typeof(SendActivity)));
            }

            ITypeProvider typeProvider = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;

            if (typeProvider == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                              SR2.GetString(SR2.General_MissingService, typeof(ITypeProvider).Name)));
            }

            if (sendActivity.ServiceOperationInfo == null)
            {
                validationErrors.Add(
                    new ValidationError(
                        SR2.GetString(SR2.Error_ServiceOperationInfoNotSpecified,
                                      sendActivity.Name),
                        WorkflowServicesErrorNumbers.Error_OperationInfoNotSpecified,
                        false,
                        "ServiceOperationInfo"));
            }
            else
            {
                // validate operation info
                //
                ValidationErrorCollection operationInfoValidationErrors =
                    ValidationHelper.ValidateOperationInfo(
                        sendActivity,
                        sendActivity.ServiceOperationInfo,
                        manager);

                validationErrors.AddRange(operationInfoValidationErrors);

                // do not validate parameter binding if the operation info is not valid
                // we might generate noise and false positives.
                //
                if (operationInfoValidationErrors.Count == 0)
                {
                    validationErrors.AddRange(
                        ValidationHelper.ValidateParameterBindings(sendActivity, sendActivity.ServiceOperationInfo,
                                                                   sendActivity.ParameterBindings, manager));
                }

                // validate the endpoint
                //
                validationErrors.AddRange(
                    ValidationHelper.ValidateChannelToken(sendActivity, manager));
            }

            return(validationErrors);
        }
#pragma warning disable 56504
        public SendActivityEventArgs(SendActivity sendActivity)
        {
            this.sendActivity = sendActivity;
        }