コード例 #1
0
        internal static List <Activity> GetChildren(ActivityUtilities.ChildActivity root, ActivityUtilities.ActivityCallStack parentChain, ProcessActivityTreeOptions options)
        {
            ActivityUtilities.FinishCachingSubtree(root, parentChain, options);

            List <Activity> listOfChildren = new List <Activity>();

            foreach (Activity activity in WorkflowInspectionServices.GetActivities(root.Activity))
            {
                listOfChildren.Add(activity);
            }

            int toProcessIndex = 0;

            while (toProcessIndex < listOfChildren.Count)
            {
                foreach (Activity activity in WorkflowInspectionServices.GetActivities(listOfChildren[toProcessIndex]))
                {
                    listOfChildren.Add(activity);
                }

                toProcessIndex++;
            }

            return(listOfChildren);
        }
            private void ValidateElement(ActivityUtilities.ChildActivity childActivity, ActivityUtilities.ActivityCallStack parentChain)
            {
                Activity objA = childActivity.Activity;

                if (!this.settings.SingleLevel || object.ReferenceEquals(objA, this.rootToValidate))
                {
                    if (this.settings.HasAdditionalConstraints)
                    {
                        bool suppressGetChildrenViolations = this.settings.OnlyUseAdditionalConstraints || this.settings.SingleLevel;
                        for (Type type = objA.GetType(); type != null; type = type.BaseType)
                        {
                            IList <Constraint> list;
                            if (this.settings.AdditionalConstraints.TryGetValue(type, out list))
                            {
                                ActivityValidationServices.RunConstraints(childActivity, parentChain, list, this.options, suppressGetChildrenViolations, ref this.errors);
                            }
                            if (type.IsGenericType)
                            {
                                IList <Constraint> list2;
                                Type genericTypeDefinition = type.GetGenericTypeDefinition();
                                if ((genericTypeDefinition != null) && this.settings.AdditionalConstraints.TryGetValue(genericTypeDefinition, out list2))
                                {
                                    ActivityValidationServices.RunConstraints(childActivity, parentChain, list2, this.options, suppressGetChildrenViolations, ref this.errors);
                                }
                            }
                        }
                    }
                    if (childActivity.Activity.IsExpressionRoot)
                    {
                        if (childActivity.Activity.HasNonEmptySubtree)
                        {
                            this.expressionRoot = childActivity.Activity;
                            ActivityUtilities.FinishCachingSubtree(childActivity, parentChain, ProcessActivityTreeOptions.FullCachingOptions, new ActivityUtilities.ProcessActivityCallback(this.ValidateExpressionSubtree));
                            this.expressionRoot = null;
                        }
                        else if (childActivity.Activity.InternalCanInduceIdle)
                        {
                            Activity        activity             = childActivity.Activity;
                            RuntimeArgument boundRuntimeArgument = ActivityValidationServices.GetBoundRuntimeArgument(activity);
                            ValidationError data = new ValidationError(System.Activities.SR.CanInduceIdleActivityInArgumentExpression(boundRuntimeArgument.Name, activity.Parent.DisplayName, activity.DisplayName), true, boundRuntimeArgument.Name, activity.Parent);
                            ActivityUtilities.Add <ValidationError>(ref this.errors, data);
                        }
                    }
                }
            }
        internal static List <Activity> GetChildren(ActivityUtilities.ChildActivity root, ActivityUtilities.ActivityCallStack parentChain, ProcessActivityTreeOptions options)
        {
            ActivityUtilities.FinishCachingSubtree(root, parentChain, options);
            List <Activity> list = new List <Activity>();

            foreach (Activity activity in WorkflowInspectionServices.GetActivities(root.Activity))
            {
                list.Add(activity);
            }
            for (int i = 0; i < list.Count; i++)
            {
                foreach (Activity activity2 in WorkflowInspectionServices.GetActivities(list[i]))
                {
                    list.Add(activity2);
                }
            }
            return(list);
        }
コード例 #4
0
            private void ValidateElement(ActivityUtilities.ChildActivity childActivity, ActivityUtilities.ActivityCallStack parentChain)
            {
                Activity toValidate = childActivity.Activity;

                if (!this.settings.SingleLevel || object.ReferenceEquals(toValidate, this.rootToValidate))
                {
                    // 0. Open time violations are captured by the CacheMetadata walk.

                    // 1. Argument validations are done by the CacheMetadata walk.

                    // 2. Build constraints are done by the CacheMetadata walk.

                    // 3. Then do policy constraints
                    if (this.settings.HasAdditionalConstraints && childActivity.CanBeExecuted && parentChain.WillExecute)
                    {
                        bool suppressGetChildrenViolations = this.settings.OnlyUseAdditionalConstraints || this.settings.SingleLevel;

                        Type currentType = toValidate.GetType();

                        while (currentType != null)
                        {
                            if (this.settings.AdditionalConstraints.TryGetValue(currentType, out IList <Constraint> policyConstraints))
                            {
                                RunConstraints(childActivity, parentChain, policyConstraints, this.options, suppressGetChildrenViolations, ref this.errors);
                            }

                            if (currentType.IsGenericType)
                            {
                                Type genericDefinitionType = currentType.GetGenericTypeDefinition();
                                if (genericDefinitionType != null)
                                {
                                    if (this.settings.AdditionalConstraints.TryGetValue(genericDefinitionType, out IList <Constraint> genericTypePolicyConstraints))
                                    {
                                        RunConstraints(childActivity, parentChain, genericTypePolicyConstraints, this.options, suppressGetChildrenViolations, ref this.errors);
                                    }
                                }
                            }
                            currentType = currentType.BaseType;
                        }
                    }

                    //4. Validate if the argument expression subtree contains an activity that can induce idle.
                    if (childActivity.Activity.IsExpressionRoot)
                    {
                        if (childActivity.Activity.HasNonEmptySubtree)
                        {
                            this.expressionRoot = childActivity.Activity;
                            // Back-compat: In Dev10 we always used ProcessActivityTreeOptions.FullCachingOptions here, and ignored this.options.
                            // So we need to continue to do that, unless the new Dev11 flag SkipRootConfigurationValidation is passed.
                            ProcessActivityTreeOptions options = this.options.SkipRootConfigurationValidation ? this.options : ProcessActivityTreeOptions.FullCachingOptions;
                            ActivityUtilities.FinishCachingSubtree(childActivity, parentChain, options, ValidateExpressionSubtree);
                            this.expressionRoot = null;
                        }
                        else if (childActivity.Activity.InternalCanInduceIdle)
                        {
                            Activity        activity        = childActivity.Activity;
                            RuntimeArgument runtimeArgument = GetBoundRuntimeArgument(activity);
                            ValidationError error           = new ValidationError(SR.CanInduceIdleActivityInArgumentExpression(runtimeArgument.Name, activity.Parent.DisplayName, activity.DisplayName), true, runtimeArgument.Name, activity.Parent);
                            ActivityUtilities.Add(ref this.errors, error);
                        }
                    }
                }
            }