Пример #1
0
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            CompensationHandlerActivity compensation = obj as CompensationHandlerActivity;

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

            // check parent must be compensatable
            if (!(compensation.Parent is ICompensatableActivity))
            {
                validationErrors.Add(new ValidationError(SR.GetString(SR.Error_ParentDoesNotSupportCompensation), ErrorNumbers.Error_FaultHandlerActivityParentNotFaultHandlersActivity));
            }

            if (compensation.EnabledActivities.Count == 0)
            {
                validationErrors.Add(new ValidationError(SR.GetString(SR.Warning_EmptyBehaviourActivity, typeof(CompensationHandlerActivity).FullName, compensation.QualifiedName), ErrorNumbers.Warning_EmptyBehaviourActivity, true));
            }

            // compensation handlers can not contain fault handlers, compensation handler and cancellation handler
            else if (((ISupportAlternateFlow)compensation).AlternateFlowActivities.Count > 0)
            {
                validationErrors.Add(new ValidationError(SR.GetString(SR.Error_ModelingConstructsCanNotContainModelingConstructs), ErrorNumbers.Error_ModelingConstructsCanNotContainModelingConstructs));
            }

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

            if (activity == null)
            {
                throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(CompensationHandlerActivity).FullName }), "obj");
            }
            if (!(activity.Parent is ICompensatableActivity))
            {
                errors.Add(new ValidationError(SR.GetString("Error_ParentDoesNotSupportCompensation"), 0x519));
            }
            if (activity.EnabledActivities.Count == 0)
            {
                errors.Add(new ValidationError(SR.GetString("Warning_EmptyBehaviourActivity", new object[] { typeof(CompensationHandlerActivity).FullName, activity.QualifiedName }), 0x1a3, true));
                return(errors);
            }
            if (activity.AlternateFlowActivities.Count > 0)
            {
                errors.Add(new ValidationError(SR.GetString("Error_ModelingConstructsCanNotContainModelingConstructs"), 0x61f));
            }
            return(errors);
        }