public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
            {
                ValidationErrorCollection errors = System.Workflow.Activities.Common.ValidationHelpers.ValidateObject(manager, obj);

                if (errors.Count == 0)
                {
                    Activity context = manager.Context[typeof(Activity)] as Activity;
                    if (context == null)
                    {
                        throw new InvalidOperationException(SR.GetString("Error_ContextStackItemMissing", new object[] { typeof(Activity).Name }));
                    }
                    CodeCondition condition = obj as CodeCondition;
                    if ((condition != null) && condition.IsBindingSet(CodeCondition.ConditionEvent))
                    {
                        ActivityBind binding = condition.GetBinding(CodeCondition.ConditionEvent);
                        if (binding != null)
                        {
                            Activity activity = System.Workflow.Activities.Common.Helpers.ParseActivityForBind(context, binding.Name);
                            if ((activity != null) && System.Workflow.Activities.Common.Helpers.IsChildActivity(context.Parent, activity))
                            {
                                string          fullPropertyName = base.GetFullPropertyName(manager);
                                ValidationError item             = new ValidationError(SR.GetString("Error_NestedConstrainedGroupConditions", new object[] { fullPropertyName }), 0x615)
                                {
                                    PropertyName = fullPropertyName
                                };
                                errors.Add(item);
                            }
                        }
                    }
                }
                return(errors);
            }
Exemple #2
0
            public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
            {
                ValidationErrorCollection validationErrors = ValidationHelpers.ValidateObject(manager, obj);

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

                    CodeCondition codeCondition = obj as CodeCondition;
                    if (codeCondition != null && codeCondition.IsBindingSet(CodeCondition.ConditionEvent))
                    {
                        ActivityBind activityBind = codeCondition.GetBinding(CodeCondition.ConditionEvent) as ActivityBind;
                        if (activityBind != null)
                        {
                            Activity contextActivity = Helpers.ParseActivityForBind(activity, activityBind.Name);
                            if (contextActivity != null && Helpers.IsChildActivity(activity.Parent, contextActivity))
                            {
                                string          propertyName = GetFullPropertyName(manager);
                                ValidationError error        = new ValidationError(SR.GetString(SR.Error_NestedConstrainedGroupConditions, propertyName), ErrorNumbers.Error_NestedConstrainedGroupConditions);
                                error.PropertyName = propertyName;
                                validationErrors.Add(error);
                            }
                        }
                    }
                }

                return(validationErrors);
            }