コード例 #1
0
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection validationErrors = new ValidationErrorCollection(base.Validate(manager, obj));
            SetStateActivity          setState         = obj as SetStateActivity;

            if (setState == null)
            {
                throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(StateActivity).FullName }), "obj");
            }
            if (SetStateContainment.Validate(setState, validationErrors))
            {
                if (string.IsNullOrEmpty(setState.TargetStateName))
                {
                    validationErrors.Add(new ValidationError(SR.GetString("Error_PropertyNotSet", new object[] { "TargetStateName" }), 0x116, false, "TargetStateName"));
                    return(validationErrors);
                }
                StateActivity state = StateMachineHelpers.FindStateByName(StateMachineHelpers.GetRootState(StateMachineHelpers.FindEnclosingState(setState)), setState.TargetStateName);
                if (state == null)
                {
                    validationErrors.Add(new ValidationError(SR.GetError_SetStateMustPointToAState(), 0x5f3, false, "TargetStateName"));
                    return(validationErrors);
                }
                if (!StateMachineHelpers.IsLeafState(state))
                {
                    validationErrors.Add(new ValidationError(SR.GetError_SetStateMustPointToALeafNodeState(), 0x5f4, false, "TargetStateName"));
                }
            }
            return(validationErrors);
        }
コード例 #2
0
            public static bool Validate(SetStateActivity setState, ValidationErrorCollection validationErrors)
            {
                SetStateContainment containment = new SetStateContainment();

                ValidateContainment(containment, setState);

                if (!containment.validParentFound ||
                    !containment.validParentStateFound)
                {
                    validationErrors.Add(new ValidationError(SR.GetError_SetStateOnlyWorksOnStateMachineWorkflow(), ErrorNumbers.Error_SetStateOnlyWorksOnStateMachineWorkflow));
                    return(false);
                }
                return(true);
            }
コード例 #3
0
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection validationErrors = new ValidationErrorCollection(base.Validate(manager, obj));

            SetStateActivity setState = obj as SetStateActivity;

            if (setState == null)
            {
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(StateActivity).FullName), "obj");
            }

            if (!SetStateContainment.Validate(setState, validationErrors))
            {
                return(validationErrors); // could not find a valid parent
            }
            if (String.IsNullOrEmpty(setState.TargetStateName))
            {
                validationErrors.Add(new ValidationError(
                                         SR.GetString(SR.Error_PropertyNotSet, SetStateActivity.TargetStateNamePropertyName),
                                         ErrorNumbers.Error_PropertyNotSet, false,
                                         SetStateActivity.TargetStateNamePropertyName));
            }
            else
            {
                StateActivity enclosingState = StateMachineHelpers.FindEnclosingState(setState);
                Debug.Assert(enclosingState != null); // this should be caught by the SetStateContainment.Validate call above

                StateActivity rootState = StateMachineHelpers.GetRootState(enclosingState);

                StateActivity targetActivity = StateMachineHelpers.FindStateByName(
                    rootState,
                    setState.TargetStateName);
                StateActivity targetState = targetActivity as StateActivity;
                if (targetState == null)
                {
                    validationErrors.Add(new ValidationError(SR.GetError_SetStateMustPointToAState(), ErrorNumbers.Error_SetStateMustPointToAState, false, SetStateActivity.TargetStateNamePropertyName));
                }
                else
                {
                    if (!StateMachineHelpers.IsLeafState(targetState))
                    {
                        validationErrors.Add(new ValidationError(SR.GetError_SetStateMustPointToALeafNodeState(), ErrorNumbers.Error_SetStateMustPointToALeafNodeState, false, SetStateActivity.TargetStateNamePropertyName));
                    }
                }
            }

            return(validationErrors);
        }
コード例 #4
0
            private static void ValidateContainment(SetStateContainment containment, Activity activity)
            {
                Debug.Assert(activity != null);
                if (activity.Parent == null || activity.Parent == activity)
                {
                    containment.validParentFound = false;
                    return;
                }

                if (SetStateValidator.IsValidContainer(activity.Parent))
                {
                    ValidateParentState(containment, activity.Parent);
                    return;
                }

                ValidateContainment(containment, activity.Parent);
            }
コード例 #5
0
            private static void ValidateParentState(SetStateContainment containment, CompositeActivity activity)
            {
                Debug.Assert(activity != null);
                if (activity.Parent == null)
                {
                    return;
                }

                StateActivity state = activity.Parent as StateActivity;

                if (state != null)
                {
                    containment.validParentStateFound = true;
                    return;
                }

                ValidateParentState(containment, activity.Parent);
            }
コード例 #6
0
            private static void ValidateParentState(SetStateContainment containment, CompositeActivity activity)
            {
                Debug.Assert(activity != null);
                if (activity.Parent == null)
                    return;

                StateActivity state = activity.Parent as StateActivity;
                if (state != null)
                {
                    containment.validParentStateFound = true;
                    return;
                }

                ValidateParentState(containment, activity.Parent);
            }
コード例 #7
0
            private static void ValidateContainment(SetStateContainment containment, Activity activity)
            {
                Debug.Assert(activity != null);
                if (activity.Parent == null || activity.Parent == activity)
                {
                    containment.validParentFound = false;
                    return;
                }

                if (SetStateValidator.IsValidContainer(activity.Parent))
                {
                    ValidateParentState(containment, activity.Parent);
                    return;
                }

                ValidateContainment(containment, activity.Parent);
            }
コード例 #8
0
            public static bool Validate(SetStateActivity setState, ValidationErrorCollection validationErrors)
            {
                SetStateContainment containment = new SetStateContainment();
                ValidateContainment(containment, setState);

                if (!containment.validParentFound ||
                    !containment.validParentStateFound)
                {
                    validationErrors.Add(new ValidationError(SR.GetError_SetStateOnlyWorksOnStateMachineWorkflow(), ErrorNumbers.Error_SetStateOnlyWorksOnStateMachineWorkflow));
                    return false;
                }
                return true;
            }