⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 extendedpropertydescriptor.cs

📁 c#源代码
💻 CS
字号:
using System;
using System.Collections;
using System.Reflection;
using System.ComponentModel;

namespace SharpReportCore {
	/// <summary>
	/// This class supports data binding
	/// </summary>
	public class SharpPropertyDescriptor : PropertyDescriptor{
		bool readOnly = false;
		Type componentType;
		Type propertyType;
		PropertyInfo prop;

		public SharpPropertyDescriptor (string name, Type componentType, Type propertyType)
			: base (name, null)
		{
			this.componentType = componentType;
			this.propertyType = propertyType;
		}


		public override object GetValue (object component)
		{			
			if (!componentType.IsAssignableFrom(component.GetType()))
			{
				return null;
			}

			if (prop == null)
				prop = componentType.GetProperty (Name);
			object o = prop.GetValue (component, null);
			if (o is IList)
			{
				PropertyTypeHash.Instance[componentType, Name] = SharpArrayList.GetElementType((IList)o, componentType, Name);
			}
			return o;
		}

		public override void SetValue(object component,	object value) 
		{
			if (IsReadOnly)
				return;

			if (prop == null)
				prop = componentType.GetProperty (Name);

			prop.SetValue (component, value, null);
		}

		public override void ResetValue(object component) 
		{
			return;
		}

		public override bool CanResetValue(object component) 
		{
			return false;
		}

		public override bool ShouldSerializeValue(object component) 
		{
			return false;
		}

		public override Type ComponentType
		{
			get { return componentType; }
		}

		public override bool IsReadOnly
		{
			get { return readOnly; }
		}

		public override Type PropertyType
		{
			get { return propertyType; }
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -