internal static void SetPropertyValue(IServiceProvider serviceProvider, PropertyDescriptor propertyDescriptor, object component, object value) { ComponentChangeDispatcher componentChange = new ComponentChangeDispatcher(serviceProvider, component, propertyDescriptor); try { propertyDescriptor.SetValue(component, value); } catch (Exception t) { // If there was a problem setting the controls property then we get: // ArgumentException (from properties set method) // ==> Becomes inner exception of TargetInvocationException // ==> caught here // Propagate the original exception up if (t is TargetInvocationException && t.InnerException != null) { throw t.InnerException; } else { throw t; } } finally { componentChange.Dispose(); } }
public override void SetValue(object component, object value) { if (component != null) { IServiceProvider site = MemberDescriptor.GetSite(component); ComponentChangeDispatcher dispatcher = (site != null) ? new ComponentChangeDispatcher(site, component, this) : null; try { WorkflowParameterBindingCollection parameterBindings = this.GetParameterBindings(component); if (parameterBindings != null) { string key = string.Empty; if (this.Name.StartsWith("(Parameter) ", StringComparison.Ordinal)) { key = this.Name.Substring("(Parameter) ".Length); } else { key = this.Name; } WorkflowParameterBinding item = null; if (parameterBindings.Contains(key)) { item = parameterBindings[key]; } else { item = new WorkflowParameterBinding(key); parameterBindings.Add(item); } if (value is ActivityBind) { item.SetBinding(WorkflowParameterBinding.ValueProperty, value as ActivityBind); } else { item.SetValue(WorkflowParameterBinding.ValueProperty, value); } this.OnValueChanged(component, EventArgs.Empty); } } catch (Exception exception) { if ((exception is TargetInvocationException) && (exception.InnerException != null)) { throw exception.InnerException; } throw exception; } finally { if (dispatcher != null) { dispatcher.Dispose(); } } } }
internal static void SetPropertyValue(IServiceProvider serviceProvider, PropertyDescriptor propertyDescriptor, object component, object value) { ComponentChangeDispatcher dispatcher = new ComponentChangeDispatcher(serviceProvider, component, propertyDescriptor); try { propertyDescriptor.SetValue(component, value); } catch (Exception exception) { if ((exception is TargetInvocationException) && (exception.InnerException != null)) { throw exception.InnerException; } throw exception; } finally { dispatcher.Dispose(); } }
public override void SetValue(object component, object value) { object oldValue = GetValue(component); ActivityBind activityBind = value as ActivityBind; DependencyObject dependencyObj = component as DependencyObject; DependencyProperty dependencyProperty = DependencyProperty.FromName(Name, ComponentType); if (dependencyObj != null && dependencyProperty != null && activityBind != null) { ComponentChangeDispatcher componentChangeDispatcher = new ComponentChangeDispatcher(ServiceProvider, dependencyObj, this); try { if (dependencyProperty.IsEvent && ServiceProvider != null) { IEventBindingService eventBindingService = ServiceProvider.GetService(typeof(IEventBindingService)) as IEventBindingService; if (eventBindingService != null) { EventDescriptor eventDescriptor = eventBindingService.GetEvent(RealPropertyDescriptor); if (eventDescriptor != null) RealPropertyDescriptor.SetValue(component, null); } } dependencyObj.SetBinding(dependencyProperty, activityBind); base.OnValueChanged(dependencyObj, EventArgs.Empty); } finally { componentChangeDispatcher.Dispose(); } } else { if (dependencyObj != null && dependencyProperty != null && dependencyObj.IsBindingSet(dependencyProperty)) { ComponentChangeDispatcher componentChangeDispatcher = new ComponentChangeDispatcher(ServiceProvider, dependencyObj, this); try { dependencyObj.RemoveProperty(dependencyProperty); // Need to fire component changed event because this means we're clearing // out a previously set Bind value. If the new value matches the old value stored in the user data, // base.SetValue will do nothing but return. When that happens, if we don't fire a change // event here, we'll still have the activity bind in the code or xoml file. base.OnValueChanged(dependencyObj, EventArgs.Empty); } finally { componentChangeDispatcher.Dispose(); } } base.SetValue(component, value); } //Following code is for making sure that when we change the value from activity bind to actual value //and from actual value to activity bind; we need to change the UITypeEditor associated with property //from data binding editor to the editor specified by the user if (oldValue != value && ((oldValue is ActivityBind && !(value is ActivityBind)) || (!(oldValue is ActivityBind) && value is ActivityBind))) { TypeDescriptor.Refresh(component); } }
internal static void SetPropertyValue(IServiceProvider serviceProvider, PropertyDescriptor propertyDescriptor, object component, object value) { ComponentChangeDispatcher componentChange = new ComponentChangeDispatcher(serviceProvider, component, propertyDescriptor); try { propertyDescriptor.SetValue(component, value); } catch (Exception t) { // If there was a problem setting the controls property then we get: // ArgumentException (from properties set method) // ==> Becomes inner exception of TargetInvocationException // ==> caught here // Propagate the original exception up if (t is TargetInvocationException && t.InnerException != null) throw t.InnerException; else throw t; } finally { componentChange.Dispose(); } }
public override void SetValue(object component, object value) { // the logic for notifications is borrowed from ReflectPropertyDescritpor if (component == null) { return; } IServiceProvider serviceProvider = GetSite(component); ComponentChangeDispatcher componentChange = (serviceProvider != null) ? new ComponentChangeDispatcher(serviceProvider, component, this) : null; try { WorkflowParameterBindingCollection parameters = GetParameterBindings(component); if (parameters != null) { string propertyName = String.Empty; if (this.Name.StartsWith(parameterPrefix, StringComparison.Ordinal)) { propertyName = this.Name.Substring(parameterPrefix.Length); } else { propertyName = this.Name; } WorkflowParameterBinding binding = null; if (parameters.Contains(propertyName)) { binding = parameters[propertyName]; } else { binding = new WorkflowParameterBinding(propertyName); parameters.Add(binding); } if (value is ActivityBind) { binding.SetBinding(WorkflowParameterBinding.ValueProperty, value as ActivityBind); } else { binding.SetValue(WorkflowParameterBinding.ValueProperty, value); } OnValueChanged(component, EventArgs.Empty); } } catch (Exception t) { // If there was a problem setting the controls property then we get: // ArgumentException (from properties set method) // ==> Becomes inner exception of TargetInvocationException // ==> caught here // Propagate the original exception up if (t is TargetInvocationException && t.InnerException != null) { throw t.InnerException; } else { throw t; } } finally { // Now notify the change service that the change was successful. if (componentChange != null) { componentChange.Dispose(); } } }
public override void SetValue(object component, object value) { object oldValue = GetValue(component); ActivityBind activityBind = value as ActivityBind; DependencyObject dependencyObj = component as DependencyObject; DependencyProperty dependencyProperty = DependencyProperty.FromName(Name, ComponentType); if (dependencyObj != null && dependencyProperty != null && activityBind != null) { ComponentChangeDispatcher componentChangeDispatcher = new ComponentChangeDispatcher(ServiceProvider, dependencyObj, this); try { if (dependencyProperty.IsEvent && ServiceProvider != null) { IEventBindingService eventBindingService = ServiceProvider.GetService(typeof(IEventBindingService)) as IEventBindingService; if (eventBindingService != null) { EventDescriptor eventDescriptor = eventBindingService.GetEvent(RealPropertyDescriptor); if (eventDescriptor != null) { RealPropertyDescriptor.SetValue(component, null); } } } dependencyObj.SetBinding(dependencyProperty, activityBind); base.OnValueChanged(dependencyObj, EventArgs.Empty); } finally { componentChangeDispatcher.Dispose(); } } else { if (dependencyObj != null && dependencyProperty != null && dependencyObj.IsBindingSet(dependencyProperty)) { ComponentChangeDispatcher componentChangeDispatcher = new ComponentChangeDispatcher(ServiceProvider, dependencyObj, this); try { dependencyObj.RemoveProperty(dependencyProperty); // Need to fire component changed event because this means we're clearing // out a previously set Bind value. If the new value matches the old value stored in the user data, // base.SetValue will do nothing but return. When that happens, if we don't fire a change // event here, we'll still have the activity bind in the code or xoml file. base.OnValueChanged(dependencyObj, EventArgs.Empty); } finally { componentChangeDispatcher.Dispose(); } } base.SetValue(component, value); } //Following code is for making sure that when we change the value from activity bind to actual value //and from actual value to activity bind; we need to change the UITypeEditor associated with property //from data binding editor to the editor specified by the user if (oldValue != value && ((oldValue is ActivityBind && !(value is ActivityBind)) || (!(oldValue is ActivityBind) && value is ActivityBind))) { TypeDescriptor.Refresh(component); } }