Esempio n. 1
0
            public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
            {
                ValidationErrorCollection errors = new ValidationErrorCollection();

                CodeActivity code = obj as CodeActivity;

                if (code == null)
                {
                    throw new InvalidOperationException();
                }

                // This violates the P || C validation condition, but we are compiling with csc.exe here!
                if (code.GetInvocationList <EventHandler>(CodeActivity.ExecuteCodeEvent).Length == 0 &&
                    code.GetBinding(CodeActivity.ExecuteCodeEvent) == null)
                {
                    Hashtable hashtable = code.GetValue(WorkflowMarkupSerializer.EventsProperty) as Hashtable;
                    if (hashtable == null || hashtable["ExecuteCode"] == null)
                    {
                        errors.Add(ValidationError.GetNotSetValidationError("ExecuteCode"));
                    }
                }

                errors.AddRange(base.Validate(manager, obj));
                return(errors);
            }
Esempio n. 2
0
            public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
            {
                ValidationErrorCollection errors = new ValidationErrorCollection();
                CodeActivity activity            = obj as CodeActivity;

                if (activity == null)
                {
                    throw new InvalidOperationException();
                }
                if ((activity.GetInvocationList <EventHandler>(CodeActivity.ExecuteCodeEvent).Length == 0) && (activity.GetBinding(CodeActivity.ExecuteCodeEvent) == null))
                {
                    Hashtable hashtable = activity.GetValue(WorkflowMarkupSerializer.EventsProperty) as Hashtable;
                    if ((hashtable == null) || (hashtable["ExecuteCode"] == null))
                    {
                        errors.Add(ValidationError.GetNotSetValidationError("ExecuteCode"));
                    }
                }
                errors.AddRange(base.Validate(manager, obj));
                return(errors);
            }