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(); } }
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) { // 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(); } } }