This commit is contained in:
89
PROMS/VEPROMS.CSLA.Library/Config/DynamicProperties.cs
Normal file
89
PROMS/VEPROMS.CSLA.Library/Config/DynamicProperties.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public class DynamicPropertyDescriptor : PropertyDescriptor
|
||||
{
|
||||
private PropertyDescriptor _BasePropertyDescriptor;
|
||||
private DynamicTypeDescriptor _Instance;
|
||||
|
||||
public DynamicPropertyDescriptor(DynamicTypeDescriptor instance, PropertyDescriptor basePropertyDescriptor)
|
||||
: base(basePropertyDescriptor)
|
||||
{
|
||||
_Instance = instance;
|
||||
_BasePropertyDescriptor = basePropertyDescriptor;
|
||||
}
|
||||
public override bool CanResetValue(object component)
|
||||
{ return _BasePropertyDescriptor.CanResetValue(component); }
|
||||
public override Type ComponentType
|
||||
{ get { return _BasePropertyDescriptor.ComponentType; } }
|
||||
public override object GetValue(object component)
|
||||
{ return _BasePropertyDescriptor.GetValue(component); }
|
||||
public override bool IsReadOnly
|
||||
{ get { return _Instance.IsReadOnly; } }
|
||||
public override Type PropertyType
|
||||
{ get { return _BasePropertyDescriptor.PropertyType; } }
|
||||
public override void ResetValue(object component)
|
||||
{ _BasePropertyDescriptor.ResetValue(component); }
|
||||
public override bool ShouldSerializeValue(object component)
|
||||
{ return _BasePropertyDescriptor.ShouldSerializeValue(component); }
|
||||
public override void SetValue(object component, object value)
|
||||
{ _BasePropertyDescriptor.SetValue(component, value); }
|
||||
}
|
||||
[Serializable()]
|
||||
public class DynamicTypeDescriptor //: ICustomTypeDescriptor//, ISupportInitialize
|
||||
{
|
||||
[NonSerialized]
|
||||
private PropertyDescriptorCollection dynamicProps;
|
||||
private bool _IsReadOnly = false;
|
||||
internal virtual bool IsReadOnly
|
||||
{
|
||||
get { return _IsReadOnly; }
|
||||
set { _IsReadOnly = value; }
|
||||
}
|
||||
public DynamicTypeDescriptor() { }
|
||||
#region "TypeDescriptor Implementation"
|
||||
public String GetClassName()
|
||||
{ return TypeDescriptor.GetClassName(this, true); }
|
||||
public AttributeCollection GetAttributes()
|
||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
||||
public String GetComponentName()
|
||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
||||
public TypeConverter GetConverter()
|
||||
{ return TypeDescriptor.GetConverter(this, true); }
|
||||
public EventDescriptor GetDefaultEvent()
|
||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
||||
public PropertyDescriptor GetDefaultProperty()
|
||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
||||
public object GetEditor(Type editorBaseType)
|
||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
||||
public EventDescriptorCollection GetEvents()
|
||||
{ return TypeDescriptor.GetEvents(this, true); }
|
||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
||||
{
|
||||
return GetProperties();
|
||||
}
|
||||
public PropertyDescriptorCollection GetProperties()
|
||||
{
|
||||
if (dynamicProps == null)
|
||||
{
|
||||
PropertyDescriptorCollection baseProps = TypeDescriptor.GetProperties(this, true);
|
||||
dynamicProps = new PropertyDescriptorCollection(null);
|
||||
|
||||
foreach (PropertyDescriptor oProp in baseProps)
|
||||
{
|
||||
dynamicProps.Add(new DynamicPropertyDescriptor(this, oProp));
|
||||
}
|
||||
}
|
||||
return dynamicProps;
|
||||
}
|
||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
||||
{ return this; }
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user