本文整理汇总了C#中System.ComponentModel.PropertyDescriptor.AddValueChanged方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyDescriptor.AddValueChanged方法的具体用法?C# PropertyDescriptor.AddValueChanged怎么用?C# PropertyDescriptor.AddValueChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.PropertyDescriptor
的用法示例。
在下文中一共展示了PropertyDescriptor.AddValueChanged方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventMonitor
private EventMonitor(object instance, PropertyDescriptor property)
{
property.AddValueChanged(instance, (sender, e) =>
{
count++;
});
}
示例2: Initialize
/// <summary>
/// This function asigns a source and property to this viewmodel.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="property">The Property.</param>
public virtual void Initialize(object source, PropertyDescriptor property)
{
Source = source;
Property = property;
Property.AddValueChanged(source, delegate
{
OnValueChanged();
});
}
示例3: Arrange
protected override void Arrange()
{
base.Arrange();
traceOutputOptions = TraceListener.Property("TraceOutputOptions");
componentModelTraceOutputOptions = TraceListenerTypeDescriptor.GetProperties().OfType<PropertyDescriptor>().Where(x => x.Name == "TraceOutputOptions").First();
expirationPollFrequencyChanged = false;
componentModelTraceOutputOptions.AddValueChanged(TraceListenerTypeDescriptor, new EventHandler((sender, args) => expirationPollFrequencyChanged = true));
}
示例4: Arrange
protected override void Arrange()
{
base.Arrange();
expirationPollFrequency = CacheManager.Property("ExpirationPollFrequencyInSeconds");
componentModelExpirationPollFrequency = CacheManagerTypeDescriptor.GetProperties().OfType<PropertyDescriptor>().Where(x => x.Name == "ExpirationPollFrequencyInSeconds").First();
expirationPollFrequencyChanged = false;
componentModelExpirationPollFrequency.AddValueChanged(CacheManagerTypeDescriptor, new EventHandler((sender, args) => expirationPollFrequencyChanged = true));
}
示例5: Property
/// <summary>
/// Constructor
/// </summary>
/// <param name="instance"></param>
/// <param name="descriptor"></param>
/// <param name="owner"></param>
public Property(object instance, PropertyDescriptor descriptor, PropertyEditor owner)
: base(owner)
{
Instance = instance;
Descriptor = descriptor;
Name = descriptor.Name;
Header = descriptor.DisplayName;
ToolTip = descriptor.Description;
// todo: is this ok? could it be a weak event?
Descriptor.AddValueChanged(Instance, InstancePropertyChanged);
}
示例6: SetDataSource
internal override void SetDataSource(Object dataSource) {
if (this.dataSource != null && !String.IsNullOrEmpty(this.propName)) {
propInfo.RemoveValueChanged(this.dataSource, new EventHandler(PropertyChanged));
propInfo = null;
}
this.dataSource = dataSource;
if (this.dataSource != null && !String.IsNullOrEmpty(this.propName)) {
propInfo = TypeDescriptor.GetProperties(dataSource).Find(propName, true);
if (propInfo == null)
throw new ArgumentException(SR.GetString(SR.PropertyManagerPropDoesNotExist, propName, dataSource.ToString()));
propInfo.AddValueChanged(dataSource, new EventHandler(PropertyChanged));
}
}
示例7: PropertyItem
/// <summary>
/// Initializes a new instance of the <see cref="PropertyItem"/> class.
/// </summary>
public PropertyItem(PropertyDescriptor property, object instance)
{
Property = property;
Instance = instance;
ResetCommand = new Command<object>(ResetValue, CanResetValue);
EditBindingCommand = new Command<object>(ShowBindingEditor, o => !property.IsReadOnly);
EditResourceCommand = new Command<object>(ShowResourceEditor, o => !property.IsReadOnly);
_propertySortInfo = PropertySorter.GetSortInfo(property);
_markupObject = MarkupWriter.GetMarkupObjectFor(Instance);
property.AddValueChanged(instance, OnValueChanged);
_dpd = DependencyPropertyDescriptor.FromProperty(property);
}
示例8: ComponentChangeDispatcher
public ComponentChangeDispatcher(IServiceProvider serviceProvider, object component, PropertyDescriptor propertyDescriptor)
{
this.serviceProvider = serviceProvider;
this.component = component;
this.property = propertyDescriptor;
IComponentChangeService service = serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
if (service != null)
{
try
{
this.newValue = this.oldValue = propertyDescriptor.GetValue(component);
propertyDescriptor.AddValueChanged(component, new EventHandler(this.OnValueChanged));
service.OnComponentChanging(component, propertyDescriptor);
}
catch (CheckoutException exception)
{
if (exception != CheckoutException.Canceled)
{
throw exception;
}
}
}
}
示例9: ValueChangedRecord
/// <summary>
/// Constructor</summary>
/// <param name="manager">The value changed event manager</param>
/// <param name="source">The source of the value changed event</param>
/// <param name="pd">The property descriptor of the value that changed</param>
public ValueChangedRecord(ValueChangedEventManager manager, object source, PropertyDescriptor pd)
{
// keep a strong reference to the source. Normally we avoid this, but
// it's OK here since its scope is exactly the same as the strong reference
// held by the PD: begins with pd.AddValueChanged, ends with
// pd.RemoveValueChanged. This ensures that we _can_ call RemoveValueChanged
// even in cases where the source implements value-semantics (which
// confuses the PD - see 795205).
m_manager = manager;
m_source = new WeakReference(source);
m_pd = pd;
m_eventArgs = new ValueChangedEventArgs(pd);
pd.AddValueChanged(source, new EventHandler(OnValueChanged));
}
示例10: ComponentChangeDispatcher
public ComponentChangeDispatcher(IServiceProvider serviceProvider, object component, PropertyDescriptor propertyDescriptor)
{
this.serviceProvider = serviceProvider;
this.component = component;
this.property = propertyDescriptor;
IComponentChangeService changeService = serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
if (changeService != null)
{
try
{
newValue = oldValue = propertyDescriptor.GetValue(component);
propertyDescriptor.AddValueChanged(component, new EventHandler(OnValueChanged));
changeService.OnComponentChanging(component, propertyDescriptor);
}
catch (CheckoutException coEx)
{
if (coEx == CheckoutException.Canceled)
return;
throw coEx;
}
}
}
示例11: SubscribeValueChanged
/// <summary>
/// Subscribes to the ValueChanged event.
/// </summary>
/// <param name="descriptor">
/// The descriptor.
/// </param>
/// <param name="handler">
/// The handler.
/// </param>
protected void SubscribeValueChanged(PropertyDescriptor descriptor, EventHandler handler)
{
if (this.IsEnumerable)
{
var list = this.Instance as IEnumerable;
if (list == null)
{
throw new InvalidOperationException("Instance should be a list.");
}
foreach (var item in list)
{
descriptor.AddValueChanged(this.GetPropertyOwner(descriptor, item), handler);
}
}
else
{
descriptor.AddValueChanged(this.GetPropertyOwner(descriptor, this.Instance), handler);
}
}
示例12: CheckBinding
internal void CheckBinding() {
// At design time, don't check anything.
//
if (owner != null &&
owner.BindableComponent != null &&
owner.ControlAtDesignTime()) {
return;
}
// force Column to throw if it's currently a bad column.
//DataColumn tempColumn = this.Column;
// remove propertyChangedNotification when this binding is deleted
if (this.owner.BindingManagerBase != null &&
this.fieldInfo != null &&
this.owner.BindingManagerBase.IsBinding &&
!(this.owner.BindingManagerBase is CurrencyManager)) {
fieldInfo.RemoveValueChanged(owner.BindingManagerBase.Current, new EventHandler(PropValueChanged));
}
if (owner != null &&
owner.BindingManagerBase != null &&
owner.BindableComponent != null &&
owner.ComponentCreated &&
this.IsDataSourceInitialized) {
string dataField = dataMember.BindingField;
fieldInfo = owner.BindingManagerBase.GetItemProperties().Find(dataField, true);
if (owner.BindingManagerBase.DataSource != null && fieldInfo == null && dataField.Length > 0) {
throw new ArgumentException(SR.GetString(SR.ListBindingBindField, dataField), "dataMember");
}
// Do not add propertyChange notification if
// the fieldInfo is null
//
// we add an event handler to the dataSource in the BindingManagerBase because
// if the binding is of the form (Control, ControlProperty, DataSource, Property1.Property2.Property3)
// then we want to get notification from Current.Property1.Property2 and not from DataSource
// when we get the backEnd notification we push the new value into the Control's property
//
if (fieldInfo != null &&
owner.BindingManagerBase.IsBinding &&
!(this.owner.BindingManagerBase is CurrencyManager)) {
fieldInfo.AddValueChanged(this.owner.BindingManagerBase.Current, new EventHandler(PropValueChanged));
}
}
else {
fieldInfo = null;
}
}