本文整理汇总了C#中PropertyItem.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyItem.GetValue方法的具体用法?C# PropertyItem.GetValue怎么用?C# PropertyItem.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyItem
的用法示例。
在下文中一共展示了PropertyItem.GetValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldClearValue
public void ShouldClearValue()
{
BusinessObject component = new BusinessObject() { Name = "TestName" };
PropertyItem property = new PropertyItem(new PropertyGrid(), component, BusinessObject.ExtractProperty("Name"));
Assert.AreEqual<string>("TestName", property.GetValue().ToString());
property.ClearValue();
Assert.AreEqual<string>("DefaultName", property.GetValue().ToString());
}
示例2: PropertyItemValue
/// <summary>
/// Initializes a new instance of the <see cref="PropertyItemValue"/> class.
/// </summary>
/// <param name="property">The property.</param>
public PropertyItemValue(PropertyItem property)
{
if (property == null) throw new ArgumentNullException("property");
this._property = property;
_hasSubProperties = property.Converter.GetPropertiesSupported();
if (_hasSubProperties)
{
object value = property.GetValue();
PropertyDescriptorCollection descriptors = property.Converter.GetProperties(value);
foreach (PropertyDescriptor d in descriptors)
{
_subProperties.Add(new PropertyItem(property.Owner, value, d));
// TODO: Move to PropertyData as a public property
NotifyParentPropertyAttribute notifyParent = d.Attributes[KnownTypes.Attributes.NotifyParentPropertyAttribute] as NotifyParentPropertyAttribute;
if (notifyParent != null && notifyParent.NotifyParent)
{
d.AddValueChanged(value, NotifySubPropertyChanged);
}
}
}
this._property.PropertyChanged += new PropertyChangedEventHandler(ParentPropertyChanged);
}
示例3: PropertyItemValue
/// <summary>
/// Initializes a new instance of the <see cref="PropertyItemValue" /> class.
/// </summary>
/// <param name="property">The property.</param>
public PropertyItemValue(PropertyItem property)
{
if (property == null) throw new ArgumentNullException("property");
_property = property;
_hasSubProperties = property.Converter.GetPropertiesSupported();
if (_hasSubProperties)
{
var value = property.GetValue();
var descriptors = property.Converter.GetProperties(value);
foreach (PropertyDescriptor d in descriptors)
{
_subProperties.Add(new PropertyItem(property.Owner, value, d));
// TODO: Move to PropertyData as a public property
var notifyParent =
d.Attributes[KnownTypes.Attributes.NotifyParentPropertyAttribute] as NotifyParentPropertyAttribute;
if (notifyParent != null && notifyParent.NotifyParent)
{
d.AddValueChanged(value, NotifySubPropertyChanged);
}
}
}
if (property.IsCollection)
{
LoadCollectionValues();
}
_property.PropertyChanged += ParentPropertyChanged;
}
示例4: PropertyItemValue
/// <summary>
/// Initializes a new instance of the <see cref="PropertyItemValue"/> class.
/// </summary>
/// <param name="property">The property.</param>
public PropertyItemValue(PropertyItem property)
{
if (property == null) throw new ArgumentNullException("property");
this.property = property;
#region IDataErrorInfo Validation attributes loading and property value getters
// dmh - use property.Attributes instead of property.UnwrappedComponent.GetType().GetProperties() which can be empty
// - removed getters. the actual value was unused
validators = new Dictionary<string, ValidationAttribute[]> { { property.Name, property.Attributes.OfType<ValidationAttribute>().ToArray() } };
#endregion
hasSubProperties = property.Converter.GetPropertiesSupported();
if (hasSubProperties)
{
object value = property.GetValue();
if (value != null)
{
PropertyDescriptorCollection descriptors = property.Converter.GetProperties(value);
if (descriptors != null)
foreach (PropertyDescriptor d in descriptors)
{
subProperties.Add(new PropertyItem(property.Owner, value, d));
// TODO: Move to PropertyData as a public property
NotifyParentPropertyAttribute notifyParent = d.Attributes[KnownTypes.Attributes.NotifyParentPropertyAttribute] as NotifyParentPropertyAttribute;
if (notifyParent != null && notifyParent.NotifyParent)
{
d.AddValueChanged(value, NotifySubPropertyChanged);
}
}
}
}
this.property.PropertyChanged += ParentPropertyChanged;
}
示例5: PropertyItemValue
/// <summary>
/// Initializes a new instance of the <see cref="PropertyItemValue"/> class.
/// </summary>
/// <param name="property">The property.</param>
public PropertyItemValue(PropertyItem property)
{
if (property == null) throw new ArgumentNullException("property");
this._property = property;
#region IDataErrorInfo Validation attributes loading and property value getters
this._validators = this._property.UnwrappedComponent.GetType().GetProperties().
Where(componentProperties => componentProperties.GetCustomAttributes(typeof(ValidationAttribute), true).Length > 0).
ToDictionary(componentProperties => componentProperties.Name, componentProperties => (ValidationAttribute[])componentProperties.GetCustomAttributes(typeof(ValidationAttribute), true));
this._getters = this._property.UnwrappedComponent.GetType().GetProperties().
Where(componentProperties => componentProperties.GetCustomAttributes(typeof(ValidationAttribute), true).Length > 0).
ToDictionary(componentProperties => componentProperties.Name, componentProperties => new Func<object, object>(propertyWrapper => componentProperties.GetValue(propertyWrapper, null)));
#endregion
_hasSubProperties = property.Converter.GetPropertiesSupported();
if (_hasSubProperties)
{
object value = property.GetValue();
PropertyDescriptorCollection descriptors = property.Converter.GetProperties(value);
foreach (PropertyDescriptor d in descriptors)
{
_subProperties.Add(new PropertyItem(property.Owner, value, d));
// TODO: Move to PropertyData as a public property
NotifyParentPropertyAttribute notifyParent = d.Attributes[KnownTypes.Attributes.NotifyParentPropertyAttribute] as NotifyParentPropertyAttribute;
if (notifyParent != null && notifyParent.NotifyParent)
{
d.AddValueChanged(value, NotifySubPropertyChanged);
}
}
}
this._property.PropertyChanged += new PropertyChangedEventHandler(ParentPropertyChanged);
}
示例6: CollectionItems
public CollectionItems(PropertyItem propertyItem)
{
_propertyItem = propertyItem;
_values = (IList) _propertyItem.GetValue();
}