protected override void PreFilterProperties(IDictionary properties)
        {
            System.Diagnostics.Trace.WriteLine("ReturnActivity - PreFilterProperties");

            base.PreFilterProperties(properties);
            if (((ITypeProvider)base.GetService(typeof(ITypeProvider))) == null)
            {
                throw new InvalidOperationException("Missing ITypeProvider Service");
            }
            ReturnActivity activity = base.Activity as ReturnActivity;

            activity.GetParameterPropertyDescriptors(properties);
        }
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object value)
        {
            System.Diagnostics.Trace.WriteLine("ReturnActivity - dropdown list ...");

            if (typeDescriptorContext == null)
            {
                throw new ArgumentNullException("typeDescriptorContext");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            this._editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            this._context       = typeDescriptorContext;

            ReturnActivity activity = null;

            object[] instances = this._context.Instance as object[];
            if (instances != null && instances.Length > 0)
            {
                activity = instances[0] as ReturnActivity;
            }
            else
            {
                activity = this._context.Instance as ReturnActivity;
            }

            ListBox lb = this.CreateDropDownList(activity);

            lb.BorderStyle           = BorderStyle.None;
            lb.SelectedIndexChanged += new EventHandler(this.dataSourceDropDown_SelectedIndexChanged);
            this._editorService.DropDownControl(lb);

            return((this._selectedObject != null && lb.SelectedIndex != -1) ? this._selectedObject : value);
        }
示例#3
0
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            #region validate Activity
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            ValidationErrorCollection collection = base.Validate(manager, obj);
            if (collection.HasErrors)
            {
                return(collection);
            }

            ReturnActivity activity = obj as ReturnActivity;
            collection.Clear();

            if (activity == null)
            {
                throw new NullReferenceException("activity");
            }

            if (activity.Parent != null)
            {
                //int lastIndex = activity.Parent.Activities.Count - 1;
                //if (activity.Parent.Activities[lastIndex].QualifiedName != activity.QualifiedName)
                //{
                //    collection.Add(new ValidationError("Activity must be at last position).", 0));
                //    return collection;
                //}
            }
            #endregion

            #region validate Properties (In Order)
            try
            {
                if (activity.Parent != null)
                {
                    if (string.IsNullOrEmpty(activity.ConnectorActivityName))
                    {
                        collection.Add(ValidationError.GetNotSetValidationError("ConnectorActivityName"));
                        return(collection);
                    }

                    if (activity.ConnectorActivityName != "(None)")
                    {
                        Activity connector = Helpers.GetRootActivity(activity).GetActivityByName(activity.ConnectorActivityName, false) as Activity;
                        if (connector != null)
                        {
                            string methodname = connector.GetType().InvokeMember("MethodName", BindingFlags.ExactBinding | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance, null, connector, new object[0], CultureInfo.InvariantCulture) as string;
                            if (string.IsNullOrEmpty(methodname))
                            {
                                activity.ConnectorActivityName = default(string);
                                collection.Add(new ValidationError("Missing corresponding ConnectorActivity (MethodName)", 0));
                                return(collection);
                            }
                            Type type = connector.GetType().InvokeMember("Type", BindingFlags.ExactBinding | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance, null, connector, new object[0], CultureInfo.InvariantCulture) as Type;
                            if (type == null)
                            {
                                collection.Add(new ValidationError("Missing corresponding ConnectorActivity (Type)", 0));
                                return(collection);
                            }
                        }
                        else
                        {
                            activity.ConnectorActivityName = default(string);
                            collection.Add(new ValidationError("Missing corresponding ConnectorActivity", 0));
                            return(collection);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
            #endregion

            return(collection);
        }
示例#4
0
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            Trace.WriteLine("OperationContractWorkflowValidator");

            #region validate Activity
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            ValidationErrorCollection collection = base.Validate(manager, obj);
            if (collection.HasErrors)
            {
                return(collection);
            }

            OperationContractWorkflowBase activity = obj as OperationContractWorkflowBase;
            collection.Clear();

            if (activity == null)
            {
                throw new NullReferenceException("activity");
            }

            #endregion

            #region validate Properties (In Order)
            if (activity.Type == null)
            {
                collection.Add(new ValidationError("The Type property is invalid (null).", 0, true, "Type"));
                return(collection);
            }
            if (!activity.Type.IsInterface)
            {
                collection.Add(new ValidationError("The Type is not Interface", 0, false, "Type"));
                return(collection);
            }
            if (string.IsNullOrEmpty(activity.MethodName))
            {
                collection.Add(ValidationError.GetNotSetValidationError("MethodName"));
                return(collection);
            }
            if (activity.Type.GetMethod(activity.MethodName).ReturnType != typeof(void))
            {
                bool bExist = false;
                foreach (Activity item in activity.EnabledActivities)
                {
                    if (item is ReturnActivity)
                    {
                        ReturnActivity rra = item as ReturnActivity;
                        if (rra.ConnectorActivityName == activity.QualifiedName)
                        {
                            bExist = true;
                            break;
                        }
                    }
                }
                if (!bExist)
                {
                    collection.Add(new ValidationError("Missing corresponding ReturnActivity for handling a return value", 0));
                    return(collection);
                }
            }
            #endregion

            return(collection);
        }