コード例 #1
0
        protected override void OnActivityChanged(ActivityChangedEventArgs e)
        {
            Trace.WriteLine("ConnectorActivity - OnActivityChanged");

            base.OnActivityChanged(e);
            if (e.Member != null)
            {
                if (e.Member.Name == "Type")
                {
                    if (base.Activity.Site != null)
                    {
                        Activity           activity   = e.Activity;
                        PropertyDescriptor descriptor = TypeDescriptor.GetProperties(base.Activity)["MethodName"];
                        if (descriptor != null)
                        {
                            descriptor.SetValue(base.Activity, string.Empty);
                        }
                    }
                }
                else if (e.Member.Name == "MethodName")
                {
                    OperationContractWorkflowBase activity = e.Activity as OperationContractWorkflowBase;
                    if (activity != null)
                    {
                        activity.Parameters.Clear();

                        //refresh corresponding ReturnActivity
                        if (activity.Parent == null)
                        {
                            foreach (Activity item in activity.Activities)
                            {
                                if ((item is ReturnActivity) && (((ReturnActivity)item).ConnectorActivityName == activity.QualifiedName))
                                {
                                    (item as ReturnActivity).ConnectorActivityName = string.Empty;
                                    (item as ReturnActivity).Parameters.Clear();
                                    TypeDescriptor.Refresh(item);
                                }
                            }
                        }
                    }
                }
                if ((e.Member.Name == "Type") || (e.Member.Name == "MethodName"))
                {
                    TypeDescriptor.Refresh(e.Activity);
                }
            }
        }
コード例 #2
0
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);
            OperationContractWorkflowBase activity = this.Activity as OperationContractWorkflowBase;

            if (activity != null && activity.Type != null && activity.MethodName != null)
            {
                MethodInfo mi = activity.Type.GetMethod(activity.MethodName);
                if (mi != null)
                {
                    //get the parameters and add them as properties
                    ParameterInfo[] pis = mi.GetParameters();
                    if (pis != null)
                    {
                        foreach (ParameterInfo pi in pis)
                        {
                            //add a new parameter
                            properties[pi.Name] = new ParameterBindingPropertyDescriptor <ConnectorActivity>(pi.Name, pi.ParameterType, new Attribute[] { new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden), new BrowsableAttribute(true), new CategoryAttribute("Parameters"), new DescriptionAttribute(pi.ParameterType.FullName), new EditorAttribute(typeof(BindUITypeEditor), typeof(UITypeEditor)) });
                        }
                    }
                }
            }
        }
コード例 #3
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);
        }