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;
        }
Exemple #2
0
        private ValidationErrorCollection ValidateEvent(Activity activity, DependencyProperty dependencyProperty, object propValue, ValidationManager manager)
        {
            ValidationErrorCollection validationErrors = new ValidationErrorCollection();

            if (propValue is string && !string.IsNullOrEmpty((string)propValue))
            {
                bool     handlerExists     = false;
                Type     objType           = null;
                Activity rootActivity      = Helpers.GetRootActivity(activity);
                Activity enclosingActivity = Helpers.GetEnclosingActivity(activity);
                string   typeName          = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
                if (rootActivity == enclosingActivity && !string.IsNullOrEmpty(typeName))
                {
                    ITypeProvider typeProvider = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
                    if (typeProvider == null)
                    {
                        throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));
                    }

                    objType = typeProvider.GetType(typeName);
                }
                else
                {
                    objType = enclosingActivity.GetType();
                }

                if (objType != null)
                {
                    MethodInfo invokeMethod = dependencyProperty.PropertyType.GetMethod("Invoke");
                    if (invokeMethod != null)
                    {
                        // resolve the method
                        List <Type> paramTypes = new List <Type>();
                        foreach (ParameterInfo paramInfo in invokeMethod.GetParameters())
                        {
                            paramTypes.Add(paramInfo.ParameterType);
                        }

                        MethodInfo methodInfo = Helpers.GetMethodExactMatch(objType, propValue as string, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy, null, paramTypes.ToArray(), null);
                        if (methodInfo != null && TypeProvider.IsAssignable(invokeMethod.ReturnType, methodInfo.ReturnType))
                        {
                            handlerExists = true;
                        }
                    }
                }

                if (!handlerExists)
                {
                    ValidationError error = new ValidationError(SR.GetString(SR.Error_CantResolveEventHandler, dependencyProperty.Name, propValue as string), ErrorNumbers.Error_CantResolveEventHandler);
                    error.PropertyName = GetFullPropertyName(manager);
                    validationErrors.Add(error);
                }
            }

            return(validationErrors);
        }
        private ValidationErrorCollection ValidateEvent(Activity activity, DependencyProperty dependencyProperty, object propValue, ValidationManager manager)
        {
            ValidationErrorCollection errors = new ValidationErrorCollection();

            if ((propValue is string) && !string.IsNullOrEmpty((string)propValue))
            {
                bool     flag              = false;
                Type     type              = null;
                Activity rootActivity      = Helpers.GetRootActivity(activity);
                Activity enclosingActivity = Helpers.GetEnclosingActivity(activity);
                string   str = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
                if ((rootActivity == enclosingActivity) && !string.IsNullOrEmpty(str))
                {
                    ITypeProvider service = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
                    if (service == null)
                    {
                        throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
                    }
                    type = service.GetType(str);
                }
                else
                {
                    type = enclosingActivity.GetType();
                }
                if (type != null)
                {
                    MethodInfo method = dependencyProperty.PropertyType.GetMethod("Invoke");
                    if (method != null)
                    {
                        List <Type> list = new List <Type>();
                        foreach (ParameterInfo info2 in method.GetParameters())
                        {
                            list.Add(info2.ParameterType);
                        }
                        MethodInfo info3 = Helpers.GetMethodExactMatch(type, propValue as string, BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, list.ToArray(), null);
                        if ((info3 != null) && TypeProvider.IsAssignable(method.ReturnType, info3.ReturnType))
                        {
                            flag = true;
                        }
                    }
                }
                if (!flag)
                {
                    ValidationError item = new ValidationError(SR.GetString("Error_CantResolveEventHandler", new object[] { dependencyProperty.Name, propValue as string }), 0x60f)
                    {
                        PropertyName = base.GetFullPropertyName(manager)
                    };
                    errors.Add(item);
                }
            }
            return(errors);
        }
 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     FaultHandlerActivity activity = obj as FaultHandlerActivity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(FaultHandlerActivity).FullName }), "obj");
     }
     if (!(activity.Parent is FaultHandlersActivity))
     {
         errors.Add(new ValidationError(SR.GetString("Error_FaultHandlerActivityParentNotFaultHandlersActivity"), 0x519));
     }
     if (!(manager.GetService(typeof(ITypeProvider)) is ITypeProvider))
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
     }
     ValidationError item = null;
     if (activity.FaultType == null)
     {
         item = new ValidationError(SR.GetString("Error_TypePropertyInvalid", new object[] { "FaultType" }), 0x116) {
             PropertyName = "FaultType"
         };
         errors.Add(item);
     }
     else if (!TypeProvider.IsAssignable(typeof(Exception), activity.FaultType))
     {
         item = new ValidationError(SR.GetString("Error_TypeTypeMismatch", new object[] { "FaultType", typeof(Exception).FullName }), 0x51a) {
             PropertyName = "FaultType"
         };
         errors.Add(item);
     }
     if (activity.EnabledActivities.Count == 0)
     {
         errors.Add(new ValidationError(SR.GetString("Warning_EmptyBehaviourActivity", new object[] { typeof(FaultHandlerActivity).FullName, activity.QualifiedName }), 0x1a3, true));
     }
     if (activity.AlternateFlowActivities.Count > 0)
     {
         errors.Add(new ValidationError(SR.GetString("Error_ModelingConstructsCanNotContainModelingConstructs"), 0x61f));
     }
     return errors;
 }
 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     InvokeWebServiceActivity activity = obj as InvokeWebServiceActivity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(InvokeWebServiceActivity).FullName }), "obj");
     }
     if (activity.ProxyClass == null)
     {
         ValidationError item = new ValidationError(SR.GetString("Error_TypePropertyInvalid", new object[] { "ProxyClass" }), 0x116) {
             PropertyName = "ProxyClass"
         };
         errors.Add(item);
         return errors;
     }
     if (((ITypeProvider) manager.GetService(typeof(ITypeProvider))) == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
     }
     Type proxyClass = activity.ProxyClass;
     if ((activity.MethodName == null) || (activity.MethodName.Length == 0))
     {
         errors.Add(ValidationError.GetNotSetValidationError("MethodName"));
         return errors;
     }
     MethodInfo method = proxyClass.GetMethod(activity.MethodName);
     if (method == null)
     {
         ValidationError error2 = new ValidationError(SR.GetString("Error_MethodNotExists", new object[] { "MethodName", activity.MethodName }), 0x137) {
             PropertyName = "MethodName"
         };
         errors.Add(error2);
         return errors;
     }
     ArrayList list = new ArrayList(method.GetParameters());
     if (method.ReturnType != typeof(void))
     {
         list.Add(method.ReturnParameter);
     }
     foreach (ParameterInfo info2 in list)
     {
         string name = info2.Name;
         if (info2.Position == -1)
         {
             name = "(ReturnValue)";
         }
         object binding = null;
         if (activity.ParameterBindings.Contains(name))
         {
             if (activity.ParameterBindings[name].IsBindingSet(WorkflowParameterBinding.ValueProperty))
             {
                 binding = activity.ParameterBindings[name].GetBinding(WorkflowParameterBinding.ValueProperty);
             }
             else
             {
                 binding = activity.ParameterBindings[name].GetValue(WorkflowParameterBinding.ValueProperty);
             }
         }
         if (!activity.ParameterBindings.Contains(name) || (binding == null))
         {
             ValidationError notSetValidationError = ValidationError.GetNotSetValidationError(name);
             if (InvokeWebServiceActivity.ReservedParameterNames.Contains(name))
             {
                 notSetValidationError.PropertyName = ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(activity.GetType(), name);
             }
             notSetValidationError.PropertyName = name;
             errors.Add(notSetValidationError);
         }
         else
         {
             AccessTypes read = AccessTypes.Read;
             if (info2.IsOut || info2.IsRetval)
             {
                 read = AccessTypes.Write;
             }
             else if (info2.ParameterType.IsByRef)
             {
                 read |= AccessTypes.Write;
             }
             ValidationErrorCollection errors2 = System.Workflow.Activities.Common.ValidationHelpers.ValidateProperty(manager, activity, binding, new PropertyValidationContext(activity.ParameterBindings[name], null, name), new BindValidationContext(info2.ParameterType.IsByRef ? info2.ParameterType.GetElementType() : info2.ParameterType, read));
             if (InvokeWebServiceActivity.ReservedParameterNames.Contains(name))
             {
                 foreach (ValidationError error4 in errors2)
                 {
                     error4.PropertyName = ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(activity.GetType(), name);
                 }
             }
             errors.AddRange(errors2);
         }
     }
     if (activity.ParameterBindings.Count > list.Count)
     {
         errors.Add(new ValidationError(SR.GetString("Warning_AdditionalBindingsFound"), 0x630, true));
     }
     return errors;
 }
 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     RuleSetReference reference = obj as RuleSetReference;
     if (reference == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Messages.UnexpectedArgumentType, new object[] { typeof(RuleSetReference).FullName, "obj" }), "obj");
     }
     Activity activity = manager.Context[typeof(Activity)] as Activity;
     if (activity == null)
     {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ContextStackItemMissing, new object[] { typeof(Activity).Name }));
     }
     if (!(manager.Context[typeof(PropertyValidationContext)] is PropertyValidationContext))
     {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ContextStackItemMissing, new object[] { typeof(PropertyValidationContext).Name }));
     }
     if (!string.IsNullOrEmpty(reference.RuleSetName))
     {
         RuleDefinitions definitions = null;
         RuleSetCollection ruleSets = null;
         CompositeActivity declaringActivity = Helpers.GetDeclaringActivity(activity);
         if (declaringActivity == null)
         {
             declaringActivity = Helpers.GetRootActivity(activity) as CompositeActivity;
         }
         if (activity.Site != null)
         {
             definitions = ConditionHelper.Load_Rules_DT(activity.Site, declaringActivity);
         }
         else
         {
             definitions = ConditionHelper.Load_Rules_RT(declaringActivity);
         }
         if (definitions != null)
         {
             ruleSets = definitions.RuleSets;
         }
         if ((ruleSets == null) || !ruleSets.Contains(reference.RuleSetName))
         {
             ValidationError error = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.RuleSetNotFound, new object[] { reference.RuleSetName }), 0x576) {
                 PropertyName = base.GetFullPropertyName(manager) + ".RuleSetName"
             };
             errors.Add(error);
             return errors;
         }
         RuleSet set = ruleSets[reference.RuleSetName];
         ITypeProvider service = (ITypeProvider) manager.GetService(typeof(ITypeProvider));
         using ((WorkflowCompilationContext.Current == null) ? WorkflowCompilationContext.CreateScope(manager) : null)
         {
             RuleValidation validation = new RuleValidation(activity, service, WorkflowCompilationContext.Current.CheckTypes);
             set.Validate(validation);
             ValidationErrorCollection errors2 = validation.Errors;
             if (errors2.Count > 0)
             {
                 string fullPropertyName = base.GetFullPropertyName(manager);
                 string str6 = string.Format(CultureInfo.CurrentCulture, Messages.InvalidRuleSetExpression, new object[] { fullPropertyName });
                 int errorNumber = 0x577;
                 if (activity.Site != null)
                 {
                     foreach (ValidationError error2 in errors2)
                     {
                         ValidationError error3 = new ValidationError(error2.ErrorText, errorNumber) {
                             PropertyName = fullPropertyName + ".RuleSet Definition"
                         };
                         errors.Add(error3);
                     }
                     return errors;
                 }
                 foreach (ValidationError error4 in errors2)
                 {
                     ValidationError error5 = new ValidationError(str6 + " " + error4.ErrorText, errorNumber) {
                         PropertyName = fullPropertyName
                     };
                     errors.Add(error5);
                 }
             }
             return errors;
         }
     }
     ValidationError item = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.InvalidRuleSetName, new object[] { "RuleSetReference" }), 0x578) {
         PropertyName = base.GetFullPropertyName(manager) + ".RuleSetName"
     };
     errors.Add(item);
     return errors;
 }
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            InvokeWebServiceActivity invokeWebService = obj as InvokeWebServiceActivity;
            if (invokeWebService == null)
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(InvokeWebServiceActivity).FullName), "obj");

            if (invokeWebService.ProxyClass == null)
            {
                ValidationError error = new ValidationError(SR.GetString(SR.Error_TypePropertyInvalid, "ProxyClass"), ErrorNumbers.Error_PropertyNotSet);
                error.PropertyName = "ProxyClass";
                validationErrors.Add(error);
            }
            else
            {
                ITypeProvider typeProvider = (ITypeProvider)manager.GetService(typeof(ITypeProvider));
                if (typeProvider == null)
                    throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));

                Type proxyClassType = invokeWebService.ProxyClass;

                // Validate method
                if (invokeWebService.MethodName == null || invokeWebService.MethodName.Length == 0)
                    validationErrors.Add(ValidationError.GetNotSetValidationError("MethodName"));
                else
                {
                    MethodInfo methodInfo = proxyClassType.GetMethod(invokeWebService.MethodName);
                    if (methodInfo == null)
                    {
                        ValidationError error = new ValidationError(SR.GetString(SR.Error_MethodNotExists, "MethodName", invokeWebService.MethodName), ErrorNumbers.Error_MethodNotExists);
                        error.PropertyName = "MethodName";
                        validationErrors.Add(error);
                    }
                    else
                    {
                        ArrayList paramInfos = new ArrayList(methodInfo.GetParameters());
                        if (methodInfo.ReturnType != typeof(void))
                            paramInfos.Add(methodInfo.ReturnParameter);

                        foreach (ParameterInfo paramInfo in paramInfos)
                        {
                            string paramName = paramInfo.Name;
                            if (paramInfo.Position == -1)
                                paramName = "(ReturnValue)";

                            object paramValue = null;
                            if (invokeWebService.ParameterBindings.Contains(paramName))
                            {
                                if (invokeWebService.ParameterBindings[paramName].IsBindingSet(WorkflowParameterBinding.ValueProperty))
                                    paramValue = invokeWebService.ParameterBindings[paramName].GetBinding(WorkflowParameterBinding.ValueProperty);
                                else
                                    paramValue = invokeWebService.ParameterBindings[paramName].GetValue(WorkflowParameterBinding.ValueProperty);
                            }
                            if (!invokeWebService.ParameterBindings.Contains(paramName) || paramValue == null)
                            {
                                ValidationError validationError = ValidationError.GetNotSetValidationError(paramName);
                                if (InvokeWebServiceActivity.ReservedParameterNames.Contains(paramName))
                                    validationError.PropertyName = ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(invokeWebService.GetType(), paramName);
                                validationError.PropertyName = paramName;
                                validationErrors.Add(validationError);
                            }
                            else
                            {
                                AccessTypes access = AccessTypes.Read;
                                if (paramInfo.IsOut || paramInfo.IsRetval)
                                    access = AccessTypes.Write;
                                else if (paramInfo.ParameterType.IsByRef)
                                    access |= AccessTypes.Write;

                                ValidationErrorCollection variableErrors = ValidationHelpers.ValidateProperty(manager, invokeWebService, paramValue,
                                                                                new PropertyValidationContext(invokeWebService.ParameterBindings[paramName], null, paramName), new BindValidationContext(paramInfo.ParameterType.IsByRef ? paramInfo.ParameterType.GetElementType() : paramInfo.ParameterType, access));
                                if (InvokeWebServiceActivity.ReservedParameterNames.Contains(paramName))
                                {
                                    foreach (ValidationError validationError in variableErrors)
                                        validationError.PropertyName = ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(invokeWebService.GetType(), paramName);
                                }
                                validationErrors.AddRange(variableErrors);
                            }
                        }

                        if (invokeWebService.ParameterBindings.Count > paramInfos.Count)
                            validationErrors.Add(new ValidationError(SR.GetString(SR.Warning_AdditionalBindingsFound), ErrorNumbers.Warning_AdditionalBindingsFound, true));
                    }
                }
            }
            return validationErrors;
        }
        private ValidationErrorCollection ValidateEvent(Activity activity, DependencyProperty dependencyProperty, object propValue, ValidationManager manager)
        {
            ValidationErrorCollection validationErrors = new ValidationErrorCollection();

            if (propValue is string && !string.IsNullOrEmpty((string)propValue))
            {
                bool handlerExists = false;
                Type objType = null;
                Activity rootActivity = Helpers.GetRootActivity(activity);
                Activity enclosingActivity = Helpers.GetEnclosingActivity(activity);
                string typeName = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
                if (rootActivity == enclosingActivity && !string.IsNullOrEmpty(typeName))
                {
                    ITypeProvider typeProvider = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
                    if (typeProvider == null)
                        throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));

                    objType = typeProvider.GetType(typeName);
                }
                else
                    objType = enclosingActivity.GetType();

                if (objType != null)
                {
                    MethodInfo invokeMethod = dependencyProperty.PropertyType.GetMethod("Invoke");
                    if (invokeMethod != null)
                    {
                        // resolve the method
                        List<Type> paramTypes = new List<Type>();
                        foreach (ParameterInfo paramInfo in invokeMethod.GetParameters())
                            paramTypes.Add(paramInfo.ParameterType);

                        MethodInfo methodInfo = Helpers.GetMethodExactMatch(objType, propValue as string, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy, null, paramTypes.ToArray(), null);
                        if (methodInfo != null && TypeProvider.IsAssignable(invokeMethod.ReturnType, methodInfo.ReturnType))
                            handlerExists = true;
                    }
                }

                if (!handlerExists)
                {
                    ValidationError error = new ValidationError(SR.GetString(SR.Error_CantResolveEventHandler, dependencyProperty.Name, propValue as string), ErrorNumbers.Error_CantResolveEventHandler);
                    error.PropertyName = GetFullPropertyName(manager);
                    validationErrors.Add(error);
                }
            }

            return validationErrors;
        }
        public override ValidationErrorCollection Validate(
            ValidationManager manager,
            object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

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

            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 (receiveActivity.ServiceOperationInfo == null)
            {
                validationErrors.Add(
                    new ValidationError(
                    SR2.GetString(SR2.Error_Validation_OperationInfoNotSpecified, receiveActivity.Name),
                    WorkflowServicesErrorNumbers.Error_OperationInfoNotSpecified,
                    false,
                    "ServiceOperationInfo"));
            }
            else
            {
                // validate operation info
                //
                ValidationErrorCollection operationInfoValidationErrors =
                    ValidationHelper.ValidateOperationInfo(
                    receiveActivity,
                    receiveActivity.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(receiveActivity, receiveActivity.ServiceOperationInfo,
                        receiveActivity.ParameterBindings, manager));
                }

                // validate the context token
                //
                validationErrors.AddRange(
                    ValidationHelper.ValidateContextToken(receiveActivity, receiveActivity.ContextToken, manager));
            }

            // Check if the validation for all service operations being implemented
            // has been done previously. 
            // If it has been done once then ServiceOperationsImplementedValidationMarker 
            // will be on the context stack.
            //
            if (validationErrors.Count == 0 &&
                manager.Context[typeof(ServiceOperationsImplementedValidationMarker)] == null)
            {
                Activity rootActivity = receiveActivity;
                while (rootActivity.Parent != null)
                {
                    rootActivity = rootActivity.Parent;
                }

                validationErrors.AddRange(
                    ValidationHelper.ValidateAllServiceOperationsImplemented(
                    manager,
                    rootActivity));
            }

            return validationErrors;
        }
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            InvokeWorkflowActivity invokeWorkflow = obj as InvokeWorkflowActivity;
            if (invokeWorkflow == null)
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(InvokeWorkflowActivity).FullName), "obj");

            if (invokeWorkflow.TargetWorkflow == null)
            {
                ValidationError error = new ValidationError(SR.GetString(SR.Error_TypePropertyInvalid, "TargetWorkflow"), ErrorNumbers.Error_PropertyNotSet);
                error.PropertyName = "TargetWorkflow";
                validationErrors.Add(error);
            }
            else
            {
                ITypeProvider typeProvider = (ITypeProvider)manager.GetService(typeof(ITypeProvider));
                if (typeProvider == null)
                    throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));

                Type targetWorkflowType = invokeWorkflow.TargetWorkflow;
                if (targetWorkflowType.Assembly == null && typeProvider.LocalAssembly != null)
                {
                    Type workflowType = typeProvider.LocalAssembly.GetType(targetWorkflowType.FullName);
                    if (workflowType != null)
                        targetWorkflowType = workflowType;
                }

                if (!TypeProvider.IsAssignable(typeof(Activity), targetWorkflowType))
                {
                    ValidationError error = new ValidationError(SR.GetString(SR.Error_TypeIsNotRootActivity, "TargetWorkflow"), ErrorNumbers.Error_TypeIsNotRootActivity);
                    error.PropertyName = "TargetWorkflow";
                    validationErrors.Add(error);
                }
                else
                {
                    Activity rootActivity = null;
                    try
                    {
                        rootActivity = Activator.CreateInstance(targetWorkflowType) as Activity;
                    }
                    catch (Exception)
                    {
                        //
                    }

                    if (rootActivity == null)
                    {
                        ValidationError error = new ValidationError(SR.GetString(SR.Error_GetCalleeWorkflow, invokeWorkflow.TargetWorkflow), ErrorNumbers.Error_GetCalleeWorkflow);
                        error.PropertyName = "TargetWorkflow";
                        validationErrors.Add(error);
                    }
                    else
                    {
                        // Exec can't have activate receive.
                        Walker walker = new Walker();
                        walker.FoundActivity += delegate(Walker w, WalkerEventArgs args)
                        {
                            if ((args.CurrentActivity is WebServiceInputActivity && ((WebServiceInputActivity)args.CurrentActivity).IsActivating))
                            {
                                ValidationError validationError = new ValidationError(SR.GetString(SR.Error_ExecWithActivationReceive), ErrorNumbers.Error_ExecWithActivationReceive);
                                validationError.PropertyName = "Name";
                                validationErrors.Add(validationError);

                                args.Action = WalkerAction.Abort;
                            }
                        };

                        walker.Walk((Activity)rootActivity);

                        bool inAtomicScope = false;
                        Activity parentScope = invokeWorkflow.Parent;
                        while (parentScope != null)
                        {
                            if (parentScope is CompensatableTransactionScopeActivity || parentScope is TransactionScopeActivity)
                            {
                                inAtomicScope = true;
                                break;
                            }
                            parentScope = parentScope.Parent;
                        }

                        // Validate that if the workflow is transactional or being exec'd then it is not enclosed in an atomic scope.
                        if (inAtomicScope)
                        {
                            ValidationError validationError = new ValidationError(SR.GetString(SR.Error_ExecInAtomicScope), ErrorNumbers.Error_ExecInAtomicScope);
                            validationErrors.Add(validationError);
                        }

                        foreach (WorkflowParameterBinding paramBinding in invokeWorkflow.ParameterBindings)
                        {
                            PropertyInfo propertyInfo = null;

                            propertyInfo = targetWorkflowType.GetProperty(paramBinding.ParameterName);
                            if (propertyInfo == null)
                            {
                                ValidationError validationError = new ValidationError(SR.GetString(SR.Error_ParameterNotFound, paramBinding.ParameterName), ErrorNumbers.Error_ParameterNotFound);
                                if (InvokeWorkflowActivity.ReservedParameterNames.Contains(paramBinding.ParameterName))
                                    validationError.PropertyName = ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(invokeWorkflow.GetType(), paramBinding.ParameterName);

                                validationErrors.Add(validationError);
                                continue;
                            }

                            Type parameterType = propertyInfo.PropertyType;
                            if (paramBinding.GetBinding(WorkflowParameterBinding.ValueProperty) != null)
                            {
                                ValidationErrorCollection memberErrors = ValidationHelpers.ValidateProperty(manager, invokeWorkflow, paramBinding.GetBinding(WorkflowParameterBinding.ValueProperty), new PropertyValidationContext(paramBinding, null, paramBinding.ParameterName), new BindValidationContext(parameterType, AccessTypes.Read));

                                if (memberErrors.Count != 0)
                                {
                                    validationErrors.AddRange(memberErrors);
                                    continue;
                                }
                            }
                        }
                    }
                }
            }

            return validationErrors;
        }
 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     WebServiceInputActivity activity = obj as WebServiceInputActivity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(WebServiceInputActivity).FullName }), "obj");
     }
     if (!Helpers.IsActivityLocked(activity))
     {
         List<ParameterInfo> list;
         List<ParameterInfo> list2;
         if (activity.IsActivating)
         {
             if (WebServiceActivityHelpers.GetPreceedingActivities(activity).GetEnumerator().MoveNext())
             {
                 ValidationError item = new ValidationError(SR.GetString("Error_ActivationActivityNotFirst"), 0x568) {
                     PropertyName = "IsActivating"
                 };
                 errors.Add(item);
                 return errors;
             }
             if (WebServiceActivityHelpers.IsInsideLoop(activity, null))
             {
                 ValidationError error2 = new ValidationError(SR.GetString("Error_ActivationActivityInsideLoop"), 0x579) {
                     PropertyName = "IsActivating"
                 };
                 errors.Add(error2);
                 return errors;
             }
         }
         else if (!WebServiceActivityHelpers.GetPreceedingActivities(activity, true).GetEnumerator().MoveNext())
         {
             ValidationError error3 = new ValidationError(SR.GetString("Error_WebServiceReceiveNotMarkedActivate"), 0x569) {
                 PropertyName = "IsActivating"
             };
             errors.Add(error3);
             return errors;
         }
         ITypeProvider service = (ITypeProvider) manager.GetService(typeof(ITypeProvider));
         if (service == null)
         {
             throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
         }
         Type interfaceType = null;
         if (activity.InterfaceType != null)
         {
             interfaceType = service.GetType(activity.InterfaceType.AssemblyQualifiedName);
         }
         if (interfaceType == null)
         {
             ValidationError error4 = new ValidationError(SR.GetString("Error_TypePropertyInvalid", new object[] { "InterfaceType" }), 0x116) {
                 PropertyName = "InterfaceType"
             };
             errors.Add(error4);
             return errors;
         }
         if (!interfaceType.IsInterface)
         {
             ValidationError error5 = new ValidationError(SR.GetString("Error_InterfaceTypeNotInterface", new object[] { "InterfaceType" }), 0x570) {
                 PropertyName = "InterfaceType"
             };
             errors.Add(error5);
             return errors;
         }
         if (string.IsNullOrEmpty(activity.MethodName))
         {
             errors.Add(ValidationError.GetNotSetValidationError("MethodName"));
             return errors;
         }
         MethodInfo interfaceMethod = Helpers.GetInterfaceMethod(interfaceType, activity.MethodName);
         if (interfaceMethod == null)
         {
             ValidationError error6 = new ValidationError(SR.GetString("Error_MethodNotExists", new object[] { "MethodName", activity.MethodName }), 0x137) {
                 PropertyName = "MethodName"
             };
             errors.Add(error6);
             return errors;
         }
         ValidationErrorCollection errors2 = WebServiceActivityHelpers.ValidateParameterTypes(interfaceMethod);
         if (errors2.Count > 0)
         {
             foreach (ValidationError error7 in errors2)
             {
                 error7.PropertyName = "MethodName";
             }
             errors.AddRange(errors2);
             return errors;
         }
         WebServiceActivityHelpers.GetParameterInfo(interfaceMethod, out list, out list2);
         foreach (ParameterInfo info2 in list)
         {
             string name = info2.Name;
             string parameterPropertyName = ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(activity.GetType(), name);
             Type type2 = info2.ParameterType.IsByRef ? info2.ParameterType.GetElementType() : info2.ParameterType;
             object binding = null;
             if (activity.ParameterBindings.Contains(name))
             {
                 if (activity.ParameterBindings[name].IsBindingSet(WorkflowParameterBinding.ValueProperty))
                 {
                     binding = activity.ParameterBindings[name].GetBinding(WorkflowParameterBinding.ValueProperty);
                 }
                 else
                 {
                     binding = activity.ParameterBindings[name].GetValue(WorkflowParameterBinding.ValueProperty);
                 }
             }
             if (!type2.IsPublic || !type2.IsSerializable)
             {
                 ValidationError error8 = new ValidationError(SR.GetString("Error_TypeNotPublicSerializable", new object[] { name, type2.FullName }), 0x567) {
                     PropertyName = parameterPropertyName
                 };
                 errors.Add(error8);
             }
             else if (!activity.ParameterBindings.Contains(name) || (binding == null))
             {
                 ValidationError notSetValidationError = ValidationError.GetNotSetValidationError(name);
                 notSetValidationError.PropertyName = parameterPropertyName;
                 errors.Add(notSetValidationError);
             }
             else
             {
                 AccessTypes read = AccessTypes.Read;
                 if (info2.ParameterType.IsByRef)
                 {
                     read |= AccessTypes.Write;
                 }
                 ValidationErrorCollection errors3 = System.Workflow.Activities.Common.ValidationHelpers.ValidateProperty(manager, activity, binding, new PropertyValidationContext(activity.ParameterBindings[name], null, name), new BindValidationContext(info2.ParameterType.IsByRef ? info2.ParameterType.GetElementType() : info2.ParameterType, read));
                 foreach (ValidationError error10 in errors3)
                 {
                     error10.PropertyName = parameterPropertyName;
                 }
                 errors.AddRange(errors3);
             }
         }
         if (activity.ParameterBindings.Count > list.Count)
         {
             errors.Add(new ValidationError(SR.GetString("Warning_AdditionalBindingsFound"), 0x630, true));
         }
         bool flag = false;
         foreach (Activity activity2 in WebServiceActivityHelpers.GetSucceedingActivities(activity))
         {
             if (((activity2 is WebServiceOutputActivity) && (((WebServiceOutputActivity) activity2).InputActivityName == activity.Name)) || ((activity2 is WebServiceFaultActivity) && (((WebServiceFaultActivity) activity2).InputActivityName == activity.Name)))
             {
                 flag = true;
                 break;
             }
         }
         if (((list2.Count > 0) || (interfaceMethod.ReturnType != typeof(void))) && !flag)
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceResponseNotFound"), 0x55d));
         }
     }
     return errors;
 }
 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     WebServiceFaultActivity activity = obj as WebServiceFaultActivity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(WebServiceFaultActivity).FullName }), "obj");
     }
     if (!Helpers.IsActivityLocked(activity))
     {
         List<ParameterInfo> list;
         List<ParameterInfo> list2;
         WebServiceInputActivity activity2 = null;
         if (string.IsNullOrEmpty(activity.InputActivityName))
         {
             errors.Add(ValidationError.GetNotSetValidationError("InputActivityName"));
             return errors;
         }
         ITypeProvider service = (ITypeProvider) manager.GetService(typeof(ITypeProvider));
         if (service == null)
         {
             throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
         }
         bool flag = false;
         foreach (Activity activity3 in WebServiceActivityHelpers.GetPreceedingActivities(activity))
         {
             if (((activity3 is WebServiceFaultActivity) && (string.Compare(((WebServiceFaultActivity) activity3).InputActivityName, activity.InputActivityName, StringComparison.Ordinal) == 0)) || ((activity3 is WebServiceOutputActivity) && (string.Compare(((WebServiceOutputActivity) activity3).InputActivityName, activity.InputActivityName, StringComparison.Ordinal) == 0)))
             {
                 if (activity3 is WebServiceFaultActivity)
                 {
                     errors.Add(new ValidationError(SR.GetString("Error_DuplicateWebServiceFaultFound", new object[] { activity3.Name, activity.InputActivityName }), 0x574));
                     return errors;
                 }
                 errors.Add(new ValidationError(SR.GetString("Error_DuplicateWebServiceResponseFound", new object[] { activity3.Name, activity.InputActivityName }), 0x56a));
                 return errors;
             }
         }
         foreach (Activity activity4 in WebServiceActivityHelpers.GetPreceedingActivities(activity))
         {
             if (string.Compare(activity4.QualifiedName, activity.InputActivityName, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 if (activity4 is WebServiceInputActivity)
                 {
                     activity2 = activity4 as WebServiceInputActivity;
                     flag = true;
                     break;
                 }
                 flag = false;
                 errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotValid", new object[] { activity.InputActivityName }), 0x564));
                 return errors;
             }
         }
         if (!flag)
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotFound", new object[] { activity.InputActivityName }), 0x55e));
             return errors;
         }
         Type interfaceType = null;
         if (activity2.InterfaceType != null)
         {
             interfaceType = service.GetType(activity2.InterfaceType.AssemblyQualifiedName);
         }
         if (interfaceType == null)
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotConfigured", new object[] { activity2.Name }), 0x566));
             return errors;
         }
         if (string.IsNullOrEmpty(activity2.MethodName))
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotConfigured", new object[] { activity2.Name }), 0x566));
             return errors;
         }
         MethodInfo interfaceMethod = Helpers.GetInterfaceMethod(interfaceType, activity2.MethodName);
         if (interfaceMethod == null)
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotConfigured", new object[] { activity2.Name }), 0x566));
             return errors;
         }
         WebServiceActivityHelpers.GetParameterInfo(interfaceMethod, out list, out list2);
         if (list2.Count == 0)
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceFaultNotNeeded"), 0x57a));
             return errors;
         }
     }
     return errors;
 }
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }
            if (manager.Context == null)
            {
                throw new InvalidOperationException(Messages.ContextStackMissing);
            }

            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            RuleConditionReference declarativeCondition = obj as RuleConditionReference;
            if (declarativeCondition == null)
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.UnexpectedArgumentType, typeof(RuleConditionReference).FullName, "obj");
                throw new ArgumentException(message, "obj");
            }

            Activity activity = manager.Context[typeof(Activity)] as Activity;
            if (activity == null)
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.ContextStackItemMissing, typeof(Activity).Name);
                throw new InvalidOperationException(message);
            }

            PropertyValidationContext validationContext = manager.Context[typeof(PropertyValidationContext)] as PropertyValidationContext;
            if (validationContext == null)
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.ContextStackItemMissing, typeof(PropertyValidationContext).Name);
                throw new InvalidOperationException(message);
            }
            if (!string.IsNullOrEmpty(declarativeCondition.ConditionName))
            {
                RuleDefinitions rules = null;
                RuleConditionCollection conditionDefinitions = null;

                CompositeActivity declaringActivity = Helpers.GetDeclaringActivity(activity);
                if (declaringActivity == null)
                {
                    declaringActivity = Helpers.GetRootActivity(activity) as CompositeActivity;
                }
                if (activity.Site != null)
                    rules = ConditionHelper.Load_Rules_DT(activity.Site, declaringActivity);
                else
                    rules = ConditionHelper.Load_Rules_RT(declaringActivity);

                if (rules != null)
                    conditionDefinitions = rules.Conditions;

                if (conditionDefinitions == null || !conditionDefinitions.Contains(declarativeCondition.ConditionName))
                {
                    string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionNotFound, declarativeCondition.ConditionName);
                    ValidationError validationError = new ValidationError(message, ErrorNumbers.Error_ConditionNotFound);
                    validationError.PropertyName = GetFullPropertyName(manager) + "." + "ConditionName";
                    validationErrors.Add(validationError);
                }
                else
                {
                    RuleCondition actualCondition = conditionDefinitions[declarativeCondition.ConditionName];

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

                    IDisposable localContextScope = (WorkflowCompilationContext.Current == null ? WorkflowCompilationContext.CreateScope(manager) : null);
                    try
                    {
                        RuleValidation ruleValidator = new RuleValidation(activity, typeProvider, WorkflowCompilationContext.Current.CheckTypes);
                        actualCondition.Validate(ruleValidator);

                        ValidationErrorCollection actualConditionErrors = ruleValidator.Errors;

                        if (actualConditionErrors.Count > 0)
                        {
                            string expressionPropertyName = GetFullPropertyName(manager);
                            string genericErrorMsg = string.Format(CultureInfo.CurrentCulture, Messages.InvalidConditionExpression, expressionPropertyName);
                            int errorNumber = ErrorNumbers.Error_InvalidConditionExpression;

                            if (activity.Site != null)
                            {
                                ValidationError validationError = new ValidationError(genericErrorMsg, errorNumber);
                                validationError.PropertyName = expressionPropertyName + "." + "Expression";
                                validationErrors.Add(validationError);
                            }
                            else
                            {
                                foreach (ValidationError actualError in actualConditionErrors)
                                {
                                    ValidationError validationError = new ValidationError(genericErrorMsg + " " + actualError.ErrorText, errorNumber);
                                    validationError.PropertyName = expressionPropertyName + "." + "Expression";
                                    validationErrors.Add(validationError);
                                }
                            }
                        }

                        // Test duplicates
                        foreach (RuleCondition definition in conditionDefinitions)
                        {
                            if (definition.Name == declarativeCondition.ConditionName && definition != actualCondition)
                            {
                                string message = string.Format(CultureInfo.CurrentCulture, Messages.DuplicateConditions, declarativeCondition.ConditionName);
                                ValidationError validationError = new ValidationError(message, ErrorNumbers.Error_DuplicateConditions);
                                validationError.PropertyName = GetFullPropertyName(manager) + "." + "ConditionName";
                                validationErrors.Add(validationError);
                            }
                        }
                    }
                    finally
                    {
                        if (localContextScope != null)
                        {
                            localContextScope.Dispose();
                        }
                    }
                }
            }
            else
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.InvalidConditionName, "ConditionName");
                ValidationError validationError = new ValidationError(message, ErrorNumbers.Error_InvalidConditionName);
                validationError.PropertyName = GetFullPropertyName(manager) + "." + "ConditionName";
                validationErrors.Add(validationError);
            }
            return validationErrors;
        }
        private ValidationErrorCollection ValidateActivity(ValidationManager manager, ActivityBind bind, BindValidationContext validationContext)
        {
            ValidationError error = null;
            ValidationErrorCollection validationErrors = new ValidationErrorCollection();

            Activity activity = manager.Context[typeof(Activity)] as Activity;
            if (activity == null)
                throw new InvalidOperationException(SR.GetString(SR.Error_ContextStackItemMissing, typeof(Activity).Name));

            Activity refActivity = Helpers.ParseActivityForBind(activity, bind.Name);
            if (refActivity == null)
            {
                error = (bind.Name.StartsWith("/", StringComparison.Ordinal)) ? new ValidationError(SR.GetString(SR.Error_CannotResolveRelativeActivity, bind.Name), ErrorNumbers.Error_CannotResolveRelativeActivity) : new ValidationError(SR.GetString(SR.Error_CannotResolveActivity, bind.Name), ErrorNumbers.Error_CannotResolveActivity);
                error.PropertyName = GetFullPropertyName(manager) + ".Name";
            }
            else if (bind.Path == null || bind.Path.Length == 0)
            {
                error = new ValidationError(SR.GetString(SR.Error_PathNotSetForActivitySource), ErrorNumbers.Error_PathNotSetForActivitySource);
                error.PropertyName = GetFullPropertyName(manager) + ".Path";
            }
            else
            {
                // 

                if (!bind.Name.StartsWith("/", StringComparison.Ordinal) && !ValidationHelpers.IsActivitySourceInOrder(refActivity, activity))
                {
                    error = new ValidationError(SR.GetString(SR.Error_BindActivityReference, refActivity.QualifiedName, activity.QualifiedName), ErrorNumbers.Error_BindActivityReference, true);
                    error.PropertyName = GetFullPropertyName(manager) + ".Name";
                }

                IDesignerHost designerHost = manager.GetService(typeof(IDesignerHost)) as IDesignerHost;
                WorkflowDesignerLoader loader = manager.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
                if (designerHost != null && loader != null)
                {
                    Type refActivityType = null;
                    if (designerHost.RootComponent == refActivity)
                    {
                        ITypeProvider typeProvider = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
                        if (typeProvider == null)
                            throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));

                        refActivityType = typeProvider.GetType(designerHost.RootComponentClassName);
                    }
                    else
                    {
                        refActivity.GetType();
                    }

                    if (refActivityType != null)
                    {
                        MemberInfo memberInfo = MemberBind.GetMemberInfo(refActivityType, bind.Path);
                        if (memberInfo == null || (memberInfo is PropertyInfo && !(memberInfo as PropertyInfo).CanRead))
                        {
                            error = new ValidationError(SR.GetString(SR.Error_InvalidMemberPath, refActivity.QualifiedName, bind.Path), ErrorNumbers.Error_InvalidMemberPath);
                            error.PropertyName = GetFullPropertyName(manager) + ".Path";
                        }
                        else
                        {
                            Type memberType = null;
                            if (memberInfo is FieldInfo)
                                memberType = ((FieldInfo)(memberInfo)).FieldType;
                            else if (memberInfo is PropertyInfo)
                                memberType = ((PropertyInfo)(memberInfo)).PropertyType;
                            else if (memberInfo is EventInfo)
                                memberType = ((EventInfo)(memberInfo)).EventHandlerType;

                            if (!DoesTargetTypeMatch(validationContext.TargetType, memberType, validationContext.Access))
                            {
                                if (typeof(WorkflowParameterBinding).IsAssignableFrom(memberInfo.DeclaringType))
                                {
                                    error = new ValidationError(SR.GetString(SR.Warning_ParameterBinding, bind.Path, refActivity.QualifiedName, validationContext.TargetType.FullName), ErrorNumbers.Warning_ParameterBinding, true);
                                    error.PropertyName = GetFullPropertyName(manager) + ".Path";
                                }
                                else
                                {
                                    error = new ValidationError(SR.GetString(SR.Error_TargetTypeMismatch, memberInfo.Name, memberType.FullName, validationContext.TargetType.FullName), ErrorNumbers.Error_TargetTypeMismatch);
                                    error.PropertyName = GetFullPropertyName(manager) + ".Path";
                                }
                            }
                        }
                    }
                }
                else
                {
                    MemberInfo memberInfo = MemberBind.GetMemberInfo(refActivity.GetType(), bind.Path);
                    if (memberInfo == null || (memberInfo is PropertyInfo && !(memberInfo as PropertyInfo).CanRead))
                    {
                        error = new ValidationError(SR.GetString(SR.Error_InvalidMemberPath, refActivity.QualifiedName, bind.Path), ErrorNumbers.Error_InvalidMemberPath);
                        error.PropertyName = GetFullPropertyName(manager) + ".Path";
                    }
                    else
                    {
                        DependencyProperty dependencyProperty = DependencyProperty.FromName(memberInfo.Name, memberInfo.DeclaringType);
                        object value = BindHelpers.ResolveActivityPath(refActivity, bind.Path);
                        if (value == null)
                        {
                            Type memberType = null;
                            if (memberInfo is FieldInfo)
                                memberType = ((FieldInfo)(memberInfo)).FieldType;
                            else if (memberInfo is PropertyInfo)
                                memberType = ((PropertyInfo)(memberInfo)).PropertyType;
                            else if (memberInfo is EventInfo)
                                memberType = ((EventInfo)(memberInfo)).EventHandlerType;

                            if (!TypeProvider.IsAssignable(typeof(ActivityBind), memberType) && !DoesTargetTypeMatch(validationContext.TargetType, memberType, validationContext.Access))
                            {
                                if (typeof(WorkflowParameterBinding).IsAssignableFrom(memberInfo.DeclaringType))
                                {
                                    error = new ValidationError(SR.GetString(SR.Warning_ParameterBinding, bind.Path, refActivity.QualifiedName, validationContext.TargetType.FullName), ErrorNumbers.Warning_ParameterBinding, true);
                                    error.PropertyName = GetFullPropertyName(manager) + ".Path";
                                }
                                else
                                {
                                    error = new ValidationError(SR.GetString(SR.Error_TargetTypeMismatch, memberInfo.Name, memberType.FullName, validationContext.TargetType.FullName), ErrorNumbers.Error_TargetTypeMismatch);
                                    error.PropertyName = GetFullPropertyName(manager) + ".Path";
                                }
                            }
                        }
                        // If this is the top level activity, we should not valid that the bind can be resolved because
                        // the value of bind can be set when this activity is used in another activity.
                        else if (value is ActivityBind && refActivity.Parent != null)
                        {
                            ActivityBind referencedBind = value as ActivityBind;
                            bool bindRecursionContextAdded = false;

                            // Check for recursion
                            BindRecursionContext recursionContext = manager.Context[typeof(BindRecursionContext)] as BindRecursionContext;
                            if (recursionContext == null)
                            {
                                recursionContext = new BindRecursionContext();
                                manager.Context.Push(recursionContext);
                                bindRecursionContextAdded = true;
                            }
                            if (recursionContext.Contains(activity, bind))
                            {
                                error = new ValidationError(SR.GetString(SR.Bind_ActivityDataSourceRecursionDetected), ErrorNumbers.Bind_ActivityDataSourceRecursionDetected);
                                error.PropertyName = GetFullPropertyName(manager) + ".Path";
                            }
                            else
                            {
                                recursionContext.Add(activity, bind);

                                PropertyValidationContext propertyValidationContext = null;
                                if (dependencyProperty != null)
                                    propertyValidationContext = new PropertyValidationContext(refActivity, dependencyProperty);
                                else
                                    propertyValidationContext = new PropertyValidationContext(refActivity, memberInfo as PropertyInfo, memberInfo.Name);

                                validationErrors.AddRange(ValidationHelpers.ValidateProperty(manager, refActivity, referencedBind, propertyValidationContext, validationContext));
                            }

                            if (bindRecursionContextAdded)
                                manager.Context.Pop();
                        }
                        else if (validationContext.TargetType != null && !DoesTargetTypeMatch(validationContext.TargetType, value.GetType(), validationContext.Access))
                        {
                            error = new ValidationError(SR.GetString(SR.Error_TargetTypeMismatch, memberInfo.Name, value.GetType().FullName, validationContext.TargetType.FullName), ErrorNumbers.Error_TargetTypeMismatch);
                            error.PropertyName = GetFullPropertyName(manager) + ".Path";
                        }
                    }
                }
            }

            if (error != null)
                validationErrors.Add(error);

            return validationErrors;
        }
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            WebServiceOutputActivity webServiceResponse = obj as WebServiceOutputActivity;
            if (webServiceResponse == null)
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(WebServiceOutputActivity).FullName), "obj");

            if (Helpers.IsActivityLocked(webServiceResponse))
            {
                return validationErrors;
            }

            WebServiceInputActivity webServiceReceive = null;

            if (String.IsNullOrEmpty(webServiceResponse.InputActivityName))
                validationErrors.Add(ValidationError.GetNotSetValidationError("InputActivityName"));
            else
            {
                ITypeProvider typeProvider = (ITypeProvider)manager.GetService(typeof(ITypeProvider));
                if (typeProvider == null)
                    throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));

                bool foundMatchingReceive = false;
                foreach (Activity activity in WebServiceActivityHelpers.GetPreceedingActivities(webServiceResponse))
                {
                    if ((activity is WebServiceOutputActivity && String.Compare(((WebServiceOutputActivity)activity).InputActivityName, webServiceResponse.InputActivityName, StringComparison.Ordinal) == 0) ||
                        (activity is WebServiceFaultActivity && String.Compare(((WebServiceFaultActivity)activity).InputActivityName, webServiceResponse.InputActivityName, StringComparison.Ordinal) == 0))
                    {
                        if (activity is WebServiceOutputActivity)
                            validationErrors.Add(new ValidationError(SR.GetString(SR.Error_DuplicateWebServiceResponseFound, activity.QualifiedName, webServiceResponse.InputActivityName), ErrorNumbers.Error_DuplicateWebServiceResponseFound));
                        else
                            validationErrors.Add(new ValidationError(SR.GetString(SR.Error_DuplicateWebServiceFaultFound, activity.QualifiedName, webServiceResponse.InputActivityName), ErrorNumbers.Error_DuplicateWebServiceFaultFound));
                        return validationErrors;
                    }
                }

                foreach (Activity activity in WebServiceActivityHelpers.GetPreceedingActivities(webServiceResponse))
                {
                    if (String.Compare(activity.QualifiedName, webServiceResponse.InputActivityName, StringComparison.Ordinal) == 0)
                    {
                        if (activity is WebServiceInputActivity)
                        {
                            webServiceReceive = activity as WebServiceInputActivity;
                            foundMatchingReceive = true;
                        }
                        else
                        {
                            foundMatchingReceive = false;
                            validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotValid, webServiceResponse.InputActivityName), ErrorNumbers.Error_WebServiceReceiveNotValid));
                            return validationErrors;
                        }
                        break;
                    }
                }

                if (!foundMatchingReceive)
                {
                    validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotFound, webServiceResponse.InputActivityName), ErrorNumbers.Error_WebServiceReceiveNotFound));
                    return validationErrors;
                }
                else
                {
                    Type interfaceType = null;
                    if (webServiceReceive.InterfaceType != null)
                        interfaceType = typeProvider.GetType(webServiceReceive.InterfaceType.AssemblyQualifiedName);

                    if (interfaceType == null)
                    {
                        validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotConfigured, webServiceReceive.Name), ErrorNumbers.Error_WebServiceReceiveNotConfigured));
                    }
                    else
                    {
                        // Validate method
                        if (String.IsNullOrEmpty(webServiceReceive.MethodName))
                            validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotConfigured, webServiceReceive.Name), ErrorNumbers.Error_WebServiceReceiveNotConfigured));
                        else
                        {
                            MethodInfo methodInfo = Helpers.GetInterfaceMethod(interfaceType, webServiceReceive.MethodName);

                            if (methodInfo == null)
                            {
                                validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotConfigured, webServiceReceive.Name), ErrorNumbers.Error_WebServiceReceiveNotConfigured));
                            }
                            else
                            {
                                ValidationErrorCollection parameterTypeErrors = WebServiceActivityHelpers.ValidateParameterTypes(methodInfo);
                                if (parameterTypeErrors.Count > 0)
                                {
                                    foreach (ValidationError parameterTypeError in parameterTypeErrors)
                                    {
                                        parameterTypeError.PropertyName = "InputActivityName";
                                    }
                                    validationErrors.AddRange(parameterTypeErrors);
                                }
                                else
                                {
                                    List<ParameterInfo> inputParameters, outParameters;
                                    WebServiceActivityHelpers.GetParameterInfo(methodInfo, out inputParameters, out outParameters);

                                    if (outParameters.Count == 0)
                                    {
                                        validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceResponseNotNeeded), ErrorNumbers.Error_WebServiceResponseNotNeeded));
                                    }
                                    else
                                    {
                                        // Check to see if all output parameters have a valid bindings.
                                        foreach (ParameterInfo paramInfo in outParameters)
                                        {
                                            string paramName = paramInfo.Name;
                                            Type paramType = paramInfo.ParameterType.IsByRef ? paramInfo.ParameterType.GetElementType() : paramInfo.ParameterType;

                                            if (paramInfo.Position == -1)
                                                paramName = "(ReturnValue)";

                                            object paramValue = null;
                                            if (webServiceResponse.ParameterBindings.Contains(paramName))
                                            {
                                                if (webServiceResponse.ParameterBindings[paramName].IsBindingSet(WorkflowParameterBinding.ValueProperty))
                                                    paramValue = webServiceResponse.ParameterBindings[paramName].GetBinding(WorkflowParameterBinding.ValueProperty);
                                                else
                                                    paramValue = webServiceResponse.ParameterBindings[paramName].GetValue(WorkflowParameterBinding.ValueProperty);
                                            }

                                            if (!paramType.IsPublic || !paramType.IsSerializable)
                                            {
                                                ValidationError validationError = new ValidationError(SR.GetString(SR.Error_TypeNotPublicSerializable, paramName, paramType.FullName), ErrorNumbers.Error_TypeNotPublicSerializable);
                                                validationError.PropertyName = (String.Compare(paramName, "(ReturnValue)", StringComparison.Ordinal) == 0) ? paramName : ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(webServiceReceive.GetType(), paramName);
                                                validationErrors.Add(validationError);
                                            }
                                            else if (!webServiceResponse.ParameterBindings.Contains(paramName) || paramValue == null)
                                            {
                                                ValidationError validationError = ValidationError.GetNotSetValidationError(paramName);
                                                validationError.PropertyName = (String.Compare(paramName, "(ReturnValue)", StringComparison.Ordinal) == 0) ? paramName : ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(webServiceReceive.GetType(), paramName);
                                                validationErrors.Add(validationError);
                                            }
                                            else
                                            {
                                                AccessTypes access = AccessTypes.Read;
                                                if (paramInfo.IsOut || paramInfo.IsRetval || paramInfo.Position == -1)
                                                    access = AccessTypes.Write;

                                                ValidationErrorCollection variableErrors = ValidationHelpers.ValidateProperty(manager, webServiceResponse, paramValue,
                                                                                                new PropertyValidationContext(webServiceResponse.ParameterBindings[paramName], null, paramName), new BindValidationContext(paramInfo.ParameterType.IsByRef ? paramInfo.ParameterType.GetElementType() : paramInfo.ParameterType, access));
                                                foreach (ValidationError variableError in variableErrors)
                                                {
                                                    if (String.Compare(paramName, "(ReturnValue)", StringComparison.Ordinal) != 0)
                                                        variableError.PropertyName = ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(webServiceReceive.GetType(), paramName);
                                                }
                                                validationErrors.AddRange(variableErrors);
                                            }
                                        }

                                        if (webServiceResponse.ParameterBindings.Count > outParameters.Count)
                                            validationErrors.Add(new ValidationError(SR.GetString(SR.Warning_AdditionalBindingsFound), ErrorNumbers.Warning_AdditionalBindingsFound, true));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return validationErrors;
        }
 private ValidationErrorCollection ValidateEvent(Activity activity, DependencyProperty dependencyProperty, object propValue, ValidationManager manager)
 {
     ValidationErrorCollection errors = new ValidationErrorCollection();
     if ((propValue is string) && !string.IsNullOrEmpty((string) propValue))
     {
         bool flag = false;
         Type type = null;
         Activity rootActivity = Helpers.GetRootActivity(activity);
         Activity enclosingActivity = Helpers.GetEnclosingActivity(activity);
         string str = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
         if ((rootActivity == enclosingActivity) && !string.IsNullOrEmpty(str))
         {
             ITypeProvider service = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
             if (service == null)
             {
                 throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
             }
             type = service.GetType(str);
         }
         else
         {
             type = enclosingActivity.GetType();
         }
         if (type != null)
         {
             MethodInfo method = dependencyProperty.PropertyType.GetMethod("Invoke");
             if (method != null)
             {
                 List<Type> list = new List<Type>();
                 foreach (ParameterInfo info2 in method.GetParameters())
                 {
                     list.Add(info2.ParameterType);
                 }
                 MethodInfo info3 = Helpers.GetMethodExactMatch(type, propValue as string, BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, list.ToArray(), null);
                 if ((info3 != null) && TypeProvider.IsAssignable(method.ReturnType, info3.ReturnType))
                 {
                     flag = true;
                 }
             }
         }
         if (!flag)
         {
             ValidationError item = new ValidationError(SR.GetString("Error_CantResolveEventHandler", new object[] { dependencyProperty.Name, propValue as string }), 0x60f) {
                 PropertyName = base.GetFullPropertyName(manager)
             };
             errors.Add(item);
         }
     }
     return errors;
 }
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            WebServiceFaultActivity webServiceFault = obj as WebServiceFaultActivity;

            if (webServiceFault == null)
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(WebServiceFaultActivity).FullName), "obj");

            if (Helpers.IsActivityLocked(webServiceFault))
            {
                return validationErrors;
            }

            WebServiceInputActivity webServiceReceive = null;

            if (String.IsNullOrEmpty(webServiceFault.InputActivityName))
                validationErrors.Add(ValidationError.GetNotSetValidationError("InputActivityName"));
            else
            {
                ITypeProvider typeProvider = (ITypeProvider)manager.GetService(typeof(ITypeProvider));

                if (typeProvider == null)
                    throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));

                bool foundMatchingReceive = false;
                foreach (Activity activity in WebServiceActivityHelpers.GetPreceedingActivities(webServiceFault))
                {
                    if ((activity is WebServiceFaultActivity && String.Compare(((WebServiceFaultActivity)activity).InputActivityName, webServiceFault.InputActivityName, StringComparison.Ordinal) == 0) ||
                        (activity is WebServiceOutputActivity && String.Compare(((WebServiceOutputActivity)activity).InputActivityName, webServiceFault.InputActivityName, StringComparison.Ordinal) == 0))
                    {
                        if (activity is WebServiceFaultActivity)
                            validationErrors.Add(new ValidationError(SR.GetString(SR.Error_DuplicateWebServiceFaultFound, activity.Name, webServiceFault.InputActivityName), ErrorNumbers.Error_DuplicateWebServiceFaultFound));
                        else
                            validationErrors.Add(new ValidationError(SR.GetString(SR.Error_DuplicateWebServiceResponseFound, activity.Name, webServiceFault.InputActivityName), ErrorNumbers.Error_DuplicateWebServiceResponseFound));
                        return validationErrors;
                    }
                }

                foreach (Activity activity in WebServiceActivityHelpers.GetPreceedingActivities(webServiceFault))
                {

                    if (String.Compare(activity.QualifiedName, webServiceFault.InputActivityName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if (activity is WebServiceInputActivity)
                        {
                            webServiceReceive = activity as WebServiceInputActivity;
                            foundMatchingReceive = true;
                        }
                        else
                        {
                            foundMatchingReceive = false;
                            validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotValid, webServiceFault.InputActivityName), ErrorNumbers.Error_WebServiceReceiveNotValid));
                            return validationErrors;
                        }
                        break;
                    }
                }

                if (!foundMatchingReceive)
                {
                    validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotFound, webServiceFault.InputActivityName), ErrorNumbers.Error_WebServiceReceiveNotFound));
                    return validationErrors;
                }

                Type interfaceType = null;

                if (webServiceReceive.InterfaceType != null)
                    interfaceType = typeProvider.GetType(webServiceReceive.InterfaceType.AssemblyQualifiedName);

                if (interfaceType == null)
                {
                    validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotConfigured, webServiceReceive.Name), ErrorNumbers.Error_WebServiceReceiveNotConfigured));
                    return validationErrors;
                }

                // Validate method
                if (String.IsNullOrEmpty(webServiceReceive.MethodName))
                {
                    validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotConfigured, webServiceReceive.Name), ErrorNumbers.Error_WebServiceReceiveNotConfigured));
                    return validationErrors;
                }

                MethodInfo methodInfo = Helpers.GetInterfaceMethod(interfaceType, webServiceReceive.MethodName);

                if (methodInfo == null)
                {
                    validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceReceiveNotConfigured, webServiceReceive.Name), ErrorNumbers.Error_WebServiceReceiveNotConfigured));
                    return validationErrors;
                }

                List<ParameterInfo> inputParameters, outParameters;
                WebServiceActivityHelpers.GetParameterInfo(methodInfo, out inputParameters, out outParameters);

                if (outParameters.Count == 0)
                {
                    validationErrors.Add(new ValidationError(SR.GetString(SR.Error_WebServiceFaultNotNeeded), ErrorNumbers.Error_WebServiceFaultNotNeeded));
                    return validationErrors;
                }
            }
            return validationErrors;
        }
 protected override void UpdateListViewItem(object ruleObject, ListViewItem listViewItem)
 {
     bool flag;
     RuleSet set = ruleObject as RuleSet;
     ValidationManager serviceProvider = new ValidationManager(base.Activity.Site);
     ITypeProvider service = (ITypeProvider) serviceProvider.GetService(typeof(ITypeProvider));
     RuleValidation validation = new RuleValidation(base.Activity, service, false);
     using (WorkflowCompilationContext.CreateScope(serviceProvider))
     {
         flag = set.Validate(validation);
     }
     listViewItem.Tag = set;
     listViewItem.Text = set.Name;
     string text = flag ? Messages.Yes : Messages.No;
     if (listViewItem.SubItems.Count == 1)
     {
         listViewItem.SubItems.Add(text);
     }
     else
     {
         listViewItem.SubItems[1].Text = text;
     }
 }
 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (manager.Context == null)
     {
         throw new InvalidOperationException(Messages.ContextStackMissing);
     }
     ValidationErrorCollection errors = base.Validate(manager, obj);
     RuleConditionReference reference = obj as RuleConditionReference;
     if (reference == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Messages.UnexpectedArgumentType, new object[] { typeof(RuleConditionReference).FullName, "obj" }), "obj");
     }
     Activity activity = manager.Context[typeof(Activity)] as Activity;
     if (activity == null)
     {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ContextStackItemMissing, new object[] { typeof(Activity).Name }));
     }
     if (!(manager.Context[typeof(PropertyValidationContext)] is PropertyValidationContext))
     {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ContextStackItemMissing, new object[] { typeof(PropertyValidationContext).Name }));
     }
     if (!string.IsNullOrEmpty(reference.ConditionName))
     {
         RuleDefinitions definitions = null;
         RuleConditionCollection conditions = null;
         CompositeActivity declaringActivity = Helpers.GetDeclaringActivity(activity);
         if (declaringActivity == null)
         {
             declaringActivity = Helpers.GetRootActivity(activity) as CompositeActivity;
         }
         if (activity.Site != null)
         {
             definitions = ConditionHelper.Load_Rules_DT(activity.Site, declaringActivity);
         }
         else
         {
             definitions = ConditionHelper.Load_Rules_RT(declaringActivity);
         }
         if (definitions != null)
         {
             conditions = definitions.Conditions;
         }
         if ((conditions == null) || !conditions.Contains(reference.ConditionName))
         {
             ValidationError error = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.ConditionNotFound, new object[] { reference.ConditionName }), 0x53e) {
                 PropertyName = base.GetFullPropertyName(manager) + ".ConditionName"
             };
             errors.Add(error);
             return errors;
         }
         RuleCondition condition = conditions[reference.ConditionName];
         ITypeProvider service = (ITypeProvider) manager.GetService(typeof(ITypeProvider));
         using ((WorkflowCompilationContext.Current == null) ? WorkflowCompilationContext.CreateScope(manager) : null)
         {
             RuleValidation validation = new RuleValidation(activity, service, WorkflowCompilationContext.Current.CheckTypes);
             condition.Validate(validation);
             ValidationErrorCollection errors2 = validation.Errors;
             if (errors2.Count > 0)
             {
                 string fullPropertyName = base.GetFullPropertyName(manager);
                 string errorText = string.Format(CultureInfo.CurrentCulture, Messages.InvalidConditionExpression, new object[] { fullPropertyName });
                 int errorNumber = 0x558;
                 if (activity.Site != null)
                 {
                     ValidationError error2 = new ValidationError(errorText, errorNumber) {
                         PropertyName = fullPropertyName + ".Expression"
                     };
                     errors.Add(error2);
                 }
                 else
                 {
                     foreach (ValidationError error3 in errors2)
                     {
                         ValidationError error4 = new ValidationError(errorText + " " + error3.ErrorText, errorNumber) {
                             PropertyName = fullPropertyName + ".Expression"
                         };
                         errors.Add(error4);
                     }
                 }
             }
             foreach (RuleCondition condition2 in conditions)
             {
                 if ((condition2.Name == reference.ConditionName) && (condition2 != condition))
                 {
                     ValidationError error5 = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.DuplicateConditions, new object[] { reference.ConditionName }), 0x53f) {
                         PropertyName = base.GetFullPropertyName(manager) + ".ConditionName"
                     };
                     errors.Add(error5);
                 }
             }
             return errors;
         }
     }
     ValidationError item = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.InvalidConditionName, new object[] { "ConditionName" }), 0x540) {
         PropertyName = base.GetFullPropertyName(manager) + ".ConditionName"
     };
     errors.Add(item);
     return errors;
 }
        protected override void UpdateListViewItem(object ruleObject, ListViewItem listViewItem)
        {
            RuleSet ruleSet = ruleObject as RuleSet;

            ValidationManager manager = new ValidationManager(this.Activity.Site);
            ITypeProvider typeProvider = (ITypeProvider)manager.GetService(typeof(ITypeProvider));
            RuleValidation validation = new RuleValidation(this.Activity, typeProvider, false);

            bool valid;
            using (WorkflowCompilationContext.CreateScope(manager))
            {
                valid = ruleSet.Validate(validation);
            }

            listViewItem.Tag = ruleSet;
            listViewItem.Text = ruleSet.Name;
            string validText = valid ? Messages.Yes : Messages.No;
            if (listViewItem.SubItems.Count == 1)
                listViewItem.SubItems.Add(validText);
            else
                listViewItem.SubItems[1].Text = validText;
        }
 public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
 {
     ValidationErrorCollection errors = base.Validate(manager, obj);
     WebServiceOutputActivity activity = obj as WebServiceOutputActivity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(WebServiceOutputActivity).FullName }), "obj");
     }
     if (!Helpers.IsActivityLocked(activity))
     {
         List<ParameterInfo> list;
         List<ParameterInfo> list2;
         WebServiceInputActivity activity2 = null;
         if (string.IsNullOrEmpty(activity.InputActivityName))
         {
             errors.Add(ValidationError.GetNotSetValidationError("InputActivityName"));
             return errors;
         }
         ITypeProvider service = (ITypeProvider) manager.GetService(typeof(ITypeProvider));
         if (service == null)
         {
             throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
         }
         bool flag = false;
         foreach (Activity activity3 in WebServiceActivityHelpers.GetPreceedingActivities(activity))
         {
             if (((activity3 is WebServiceOutputActivity) && (string.Compare(((WebServiceOutputActivity) activity3).InputActivityName, activity.InputActivityName, StringComparison.Ordinal) == 0)) || ((activity3 is WebServiceFaultActivity) && (string.Compare(((WebServiceFaultActivity) activity3).InputActivityName, activity.InputActivityName, StringComparison.Ordinal) == 0)))
             {
                 if (activity3 is WebServiceOutputActivity)
                 {
                     errors.Add(new ValidationError(SR.GetString("Error_DuplicateWebServiceResponseFound", new object[] { activity3.QualifiedName, activity.InputActivityName }), 0x56a));
                     return errors;
                 }
                 errors.Add(new ValidationError(SR.GetString("Error_DuplicateWebServiceFaultFound", new object[] { activity3.QualifiedName, activity.InputActivityName }), 0x574));
                 return errors;
             }
         }
         foreach (Activity activity4 in WebServiceActivityHelpers.GetPreceedingActivities(activity))
         {
             if (string.Compare(activity4.QualifiedName, activity.InputActivityName, StringComparison.Ordinal) == 0)
             {
                 if (activity4 is WebServiceInputActivity)
                 {
                     activity2 = activity4 as WebServiceInputActivity;
                     flag = true;
                     break;
                 }
                 flag = false;
                 errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotValid", new object[] { activity.InputActivityName }), 0x564));
                 return errors;
             }
         }
         if (!flag)
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotFound", new object[] { activity.InputActivityName }), 0x55e));
             return errors;
         }
         Type interfaceType = null;
         if (activity2.InterfaceType != null)
         {
             interfaceType = service.GetType(activity2.InterfaceType.AssemblyQualifiedName);
         }
         if (interfaceType == null)
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotConfigured", new object[] { activity2.Name }), 0x566));
             return errors;
         }
         if (string.IsNullOrEmpty(activity2.MethodName))
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotConfigured", new object[] { activity2.Name }), 0x566));
             return errors;
         }
         MethodInfo interfaceMethod = Helpers.GetInterfaceMethod(interfaceType, activity2.MethodName);
         if (interfaceMethod == null)
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceReceiveNotConfigured", new object[] { activity2.Name }), 0x566));
             return errors;
         }
         ValidationErrorCollection errors2 = WebServiceActivityHelpers.ValidateParameterTypes(interfaceMethod);
         if (errors2.Count > 0)
         {
             foreach (ValidationError error in errors2)
             {
                 error.PropertyName = "InputActivityName";
             }
             errors.AddRange(errors2);
             return errors;
         }
         WebServiceActivityHelpers.GetParameterInfo(interfaceMethod, out list, out list2);
         if (list2.Count == 0)
         {
             errors.Add(new ValidationError(SR.GetString("Error_WebServiceResponseNotNeeded"), 0x565));
             return errors;
         }
         foreach (ParameterInfo info2 in list2)
         {
             string name = info2.Name;
             Type type2 = info2.ParameterType.IsByRef ? info2.ParameterType.GetElementType() : info2.ParameterType;
             if (info2.Position == -1)
             {
                 name = "(ReturnValue)";
             }
             object binding = null;
             if (activity.ParameterBindings.Contains(name))
             {
                 if (activity.ParameterBindings[name].IsBindingSet(WorkflowParameterBinding.ValueProperty))
                 {
                     binding = activity.ParameterBindings[name].GetBinding(WorkflowParameterBinding.ValueProperty);
                 }
                 else
                 {
                     binding = activity.ParameterBindings[name].GetValue(WorkflowParameterBinding.ValueProperty);
                 }
             }
             if (!type2.IsPublic || !type2.IsSerializable)
             {
                 ValidationError item = new ValidationError(SR.GetString("Error_TypeNotPublicSerializable", new object[] { name, type2.FullName }), 0x567) {
                     PropertyName = (string.Compare(name, "(ReturnValue)", StringComparison.Ordinal) == 0) ? name : ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(activity2.GetType(), name)
                 };
                 errors.Add(item);
             }
             else if (!activity.ParameterBindings.Contains(name) || (binding == null))
             {
                 ValidationError notSetValidationError = ValidationError.GetNotSetValidationError(name);
                 notSetValidationError.PropertyName = (string.Compare(name, "(ReturnValue)", StringComparison.Ordinal) == 0) ? name : ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(activity2.GetType(), name);
                 errors.Add(notSetValidationError);
             }
             else
             {
                 AccessTypes read = AccessTypes.Read;
                 if ((info2.IsOut || info2.IsRetval) || (info2.Position == -1))
                 {
                     read = AccessTypes.Write;
                 }
                 ValidationErrorCollection errors3 = System.Workflow.Activities.Common.ValidationHelpers.ValidateProperty(manager, activity, binding, new PropertyValidationContext(activity.ParameterBindings[name], null, name), new BindValidationContext(info2.ParameterType.IsByRef ? info2.ParameterType.GetElementType() : info2.ParameterType, read));
                 foreach (ValidationError error4 in errors3)
                 {
                     if (string.Compare(name, "(ReturnValue)", StringComparison.Ordinal) != 0)
                     {
                         error4.PropertyName = ParameterInfoBasedPropertyDescriptor.GetParameterPropertyName(activity2.GetType(), name);
                     }
                 }
                 errors.AddRange(errors3);
             }
         }
         if (activity.ParameterBindings.Count > list2.Count)
         {
             errors.Add(new ValidationError(SR.GetString("Warning_AdditionalBindingsFound"), 0x630, true));
         }
     }
     return errors;
 }
Exemple #22
0
        private ValidationErrorCollection ValidateActivity(ValidationManager manager, ActivityBind bind, BindValidationContext validationContext)
        {
            ValidationError           item   = null;
            ValidationErrorCollection errors = new ValidationErrorCollection();
            Activity activity = manager.Context[typeof(Activity)] as Activity;

            if (activity == null)
            {
                throw new InvalidOperationException(SR.GetString("Error_ContextStackItemMissing", new object[] { typeof(Activity).Name }));
            }
            Activity request = Helpers.ParseActivityForBind(activity, bind.Name);

            if (request == null)
            {
                item = bind.Name.StartsWith("/", StringComparison.Ordinal) ? new ValidationError(SR.GetString("Error_CannotResolveRelativeActivity", new object[] { bind.Name }), 0x128) : new ValidationError(SR.GetString("Error_CannotResolveActivity", new object[] { bind.Name }), 0x129);
                item.PropertyName = base.GetFullPropertyName(manager) + ".Name";
            }
            else if ((bind.Path == null) || (bind.Path.Length == 0))
            {
                item = new ValidationError(SR.GetString("Error_PathNotSetForActivitySource"), 0x12b)
                {
                    PropertyName = base.GetFullPropertyName(manager) + ".Path"
                };
            }
            else
            {
                if (!bind.Name.StartsWith("/", StringComparison.Ordinal) && !ValidationHelpers.IsActivitySourceInOrder(request, activity))
                {
                    item = new ValidationError(SR.GetString("Error_BindActivityReference", new object[] { request.QualifiedName, activity.QualifiedName }), 0x12a, true)
                    {
                        PropertyName = base.GetFullPropertyName(manager) + ".Name"
                    };
                }
                IDesignerHost          service = manager.GetService(typeof(IDesignerHost)) as IDesignerHost;
                WorkflowDesignerLoader loader  = manager.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
                if ((service != null) && (loader != null))
                {
                    Type srcType = null;
                    if (service.RootComponent == request)
                    {
                        ITypeProvider provider = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
                        if (provider == null)
                        {
                            throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
                        }
                        srcType = provider.GetType(service.RootComponentClassName);
                    }
                    else
                    {
                        request.GetType();
                    }
                    if (srcType != null)
                    {
                        MemberInfo memberInfo = MemberBind.GetMemberInfo(srcType, bind.Path);
                        if ((memberInfo == null) || ((memberInfo is PropertyInfo) && !(memberInfo as PropertyInfo).CanRead))
                        {
                            item = new ValidationError(SR.GetString("Error_InvalidMemberPath", new object[] { request.QualifiedName, bind.Path }), 300)
                            {
                                PropertyName = base.GetFullPropertyName(manager) + ".Path"
                            };
                        }
                        else
                        {
                            Type memberType = null;
                            if (memberInfo is FieldInfo)
                            {
                                memberType = ((FieldInfo)memberInfo).FieldType;
                            }
                            else if (memberInfo is PropertyInfo)
                            {
                                memberType = ((PropertyInfo)memberInfo).PropertyType;
                            }
                            else if (memberInfo is EventInfo)
                            {
                                memberType = ((EventInfo)memberInfo).EventHandlerType;
                            }
                            if (!DoesTargetTypeMatch(validationContext.TargetType, memberType, validationContext.Access))
                            {
                                if (typeof(WorkflowParameterBinding).IsAssignableFrom(memberInfo.DeclaringType))
                                {
                                    item = new ValidationError(SR.GetString("Warning_ParameterBinding", new object[] { bind.Path, request.QualifiedName, validationContext.TargetType.FullName }), 0x624, true)
                                    {
                                        PropertyName = base.GetFullPropertyName(manager) + ".Path"
                                    };
                                }
                                else
                                {
                                    item = new ValidationError(SR.GetString("Error_TargetTypeMismatch", new object[] { memberInfo.Name, memberType.FullName, validationContext.TargetType.FullName }), 0x12d)
                                    {
                                        PropertyName = base.GetFullPropertyName(manager) + ".Path"
                                    };
                                }
                            }
                        }
                    }
                }
                else
                {
                    MemberInfo info2 = MemberBind.GetMemberInfo(request.GetType(), bind.Path);
                    if ((info2 == null) || ((info2 is PropertyInfo) && !(info2 as PropertyInfo).CanRead))
                    {
                        item = new ValidationError(SR.GetString("Error_InvalidMemberPath", new object[] { request.QualifiedName, bind.Path }), 300)
                        {
                            PropertyName = base.GetFullPropertyName(manager) + ".Path"
                        };
                    }
                    else
                    {
                        DependencyProperty dependencyProperty = DependencyProperty.FromName(info2.Name, info2.DeclaringType);
                        object             obj2 = BindHelpers.ResolveActivityPath(request, bind.Path);
                        if (obj2 == null)
                        {
                            Type fromType = null;
                            if (info2 is FieldInfo)
                            {
                                fromType = ((FieldInfo)info2).FieldType;
                            }
                            else if (info2 is PropertyInfo)
                            {
                                fromType = ((PropertyInfo)info2).PropertyType;
                            }
                            else if (info2 is EventInfo)
                            {
                                fromType = ((EventInfo)info2).EventHandlerType;
                            }
                            if (!TypeProvider.IsAssignable(typeof(ActivityBind), fromType) && !DoesTargetTypeMatch(validationContext.TargetType, fromType, validationContext.Access))
                            {
                                if (typeof(WorkflowParameterBinding).IsAssignableFrom(info2.DeclaringType))
                                {
                                    item = new ValidationError(SR.GetString("Warning_ParameterBinding", new object[] { bind.Path, request.QualifiedName, validationContext.TargetType.FullName }), 0x624, true)
                                    {
                                        PropertyName = base.GetFullPropertyName(manager) + ".Path"
                                    };
                                }
                                else
                                {
                                    item = new ValidationError(SR.GetString("Error_TargetTypeMismatch", new object[] { info2.Name, fromType.FullName, validationContext.TargetType.FullName }), 0x12d)
                                    {
                                        PropertyName = base.GetFullPropertyName(manager) + ".Path"
                                    };
                                }
                            }
                        }
                        else if ((obj2 is ActivityBind) && (request.Parent != null))
                        {
                            ActivityBind         bind2   = obj2 as ActivityBind;
                            bool                 flag    = false;
                            BindRecursionContext context = manager.Context[typeof(BindRecursionContext)] as BindRecursionContext;
                            if (context == null)
                            {
                                context = new BindRecursionContext();
                                manager.Context.Push(context);
                                flag = true;
                            }
                            if (context.Contains(activity, bind))
                            {
                                item = new ValidationError(SR.GetString("Bind_ActivityDataSourceRecursionDetected"), 0x12f)
                                {
                                    PropertyName = base.GetFullPropertyName(manager) + ".Path"
                                };
                            }
                            else
                            {
                                context.Add(activity, bind);
                                PropertyValidationContext propertyValidationContext = null;
                                if (dependencyProperty != null)
                                {
                                    propertyValidationContext = new PropertyValidationContext(request, dependencyProperty);
                                }
                                else
                                {
                                    propertyValidationContext = new PropertyValidationContext(request, info2 as PropertyInfo, info2.Name);
                                }
                                errors.AddRange(ValidationHelpers.ValidateProperty(manager, request, bind2, propertyValidationContext, validationContext));
                            }
                            if (flag)
                            {
                                manager.Context.Pop();
                            }
                        }
                        else if ((validationContext.TargetType != null) && !DoesTargetTypeMatch(validationContext.TargetType, obj2.GetType(), validationContext.Access))
                        {
                            item = new ValidationError(SR.GetString("Error_TargetTypeMismatch", new object[] { info2.Name, obj2.GetType().FullName, validationContext.TargetType.FullName }), 0x12d)
                            {
                                PropertyName = base.GetFullPropertyName(manager) + ".Path"
                            };
                        }
                    }
                }
            }
            if (item != null)
            {
                errors.Add(item);
            }
            return(errors);
        }