当前位置: 首页>>代码示例>>C#>>正文


C# PropertyItem.GetValue方法代码示例

本文整理汇总了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());
        }
开发者ID:GonzRu,项目名称:WPG,代码行数:11,代码来源:PropertyItemTest.cs

示例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);
        }
开发者ID:GonzRu,项目名称:WPG,代码行数:30,代码来源:PropertyItemValue.cs

示例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;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:36,代码来源:PropertyItemValue.cs

示例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;
        }
开发者ID:denkhaus,项目名称:WPG,代码行数:42,代码来源:PropertyItemValue.cs

示例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);
        }
开发者ID:baks,项目名称:WPG,代码行数:42,代码来源:PropertyItemValue.cs

示例6: CollectionItems

		public CollectionItems(PropertyItem propertyItem)
		{
			_propertyItem = propertyItem;
			_values = (IList) _propertyItem.GetValue();
		}
开发者ID:stewmc,项目名称:vixen,代码行数:5,代码来源:CollectionItems.cs


注:本文中的PropertyItem.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。