Beispiel #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider serviceProvider, object value)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            this.serviceProvider = serviceProvider;

            object returnValue = value;

            if (context != null && context.PropertyDescriptor is DynamicPropertyDescriptor)
            {
                try
                {
                    using (ActivityBindForm bindDialog = new ActivityBindForm(this.serviceProvider, context))
                    {
                        if (DialogResult.OK == bindDialog.ShowDialog())
                        {
                            //Now that OK has been pressed in the dialog we need to create members if necessary
                            if (bindDialog.CreateNew)
                            {
                                //Emit the field / property as required
                                if (bindDialog.CreateNewProperty)
                                {
                                    List <CustomProperty> properties = CustomActivityDesignerHelper.GetCustomProperties(context);
                                    if (properties != null)
                                    {
                                        properties.Add(CustomProperty.CreateCustomProperty(this.serviceProvider, bindDialog.NewMemberName, context.PropertyDescriptor, context.Instance));
                                        CustomActivityDesignerHelper.SetCustomProperties(properties, context);
                                    }
                                }
                                else
                                {
                                    ActivityBindPropertyDescriptor.CreateField(context, bindDialog.Binding, true);
                                }
                            }
                            returnValue = bindDialog.Binding;
                        }
                    }
                }
                catch (Exception e)
                {
                    string message = SR.GetString(SR.Error_CanNotBindProperty, context.PropertyDescriptor.Name);
                    if (!String.IsNullOrEmpty(e.Message))
                    {
                        message += "\n\n" + e.Message;
                    }
                    DesignerHelpers.ShowError(context, message);
                }
            }
            else
            {
                DesignerHelpers.ShowError(this.serviceProvider, SR.GetString(SR.Error_MultipleSelectNotSupportedForBindAndPromote));
            }

            return(returnValue);
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider serviceProvider, object value)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            this.serviceProvider = serviceProvider;
            object obj2 = value;

            if ((context != null) && (context.PropertyDescriptor is DynamicPropertyDescriptor))
            {
                try
                {
                    using (ActivityBindForm form = new ActivityBindForm(this.serviceProvider, context))
                    {
                        if (DialogResult.OK != form.ShowDialog())
                        {
                            return(obj2);
                        }
                        if (form.CreateNew)
                        {
                            if (form.CreateNewProperty)
                            {
                                List <CustomProperty> customProperties = CustomActivityDesignerHelper.GetCustomProperties(context);
                                if (customProperties != null)
                                {
                                    customProperties.Add(CustomProperty.CreateCustomProperty(this.serviceProvider, form.NewMemberName, context.PropertyDescriptor, context.Instance));
                                    CustomActivityDesignerHelper.SetCustomProperties(customProperties, context);
                                }
                            }
                            else
                            {
                                ActivityBindPropertyDescriptor.CreateField(context, form.Binding, true);
                            }
                        }
                        return(form.Binding);
                    }
                }
                catch (Exception exception)
                {
                    string message = SR.GetString("Error_CanNotBindProperty", new object[] { context.PropertyDescriptor.Name });
                    if (!string.IsNullOrEmpty(exception.Message))
                    {
                        message = message + "\n\n" + exception.Message;
                    }
                    DesignerHelpers.ShowError(context, message);
                }
                return(obj2);
            }
            DesignerHelpers.ShowError(this.serviceProvider, SR.GetString("Error_MultipleSelectNotSupportedForBindAndPromote"));
            return(obj2);
        }