|
/*
* Copyright � 2005-2006 Danilo Mendez <danilo.mendez@kontac.net>
* Adolfo Socorro <ajs@esolutionspr.com>
* www.kontac.net
* All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Reflection;
namespace SmartCode.Studio.Controls
{
internal abstract class PropertyWrapper : ICustomTypeDescriptor
{
internal delegate void PropertyChangedHandler(object sender, EventArgs e);
protected ExplorerTreeNode explorerNode;
protected PropertyWrapper(ExplorerTreeNode treeNode)
{
this.explorerNode = treeNode;
}
#region ICustomTypeDescriptor Members
public AttributeCollection GetAttributes()
{
object[] customAttributes = base.GetType().GetCustomAttributes(true);
Attribute[] attributes = new Attribute[customAttributes.Length];
for (int i = 0; i < customAttributes.Length; i++)
{
attributes[i] = (Attribute)customAttributes[i];
}
return new AttributeCollection(attributes);
}
public string GetClassName()
{
return base.GetType().Name;
}
public string GetComponentName()
{
return string.Empty;
}
public TypeConverter GetConverter()
{
return null;
}
public EventDescriptor GetDefaultEvent()
{
return null;
}
public PropertyDescriptor GetDefaultProperty()
{
return null;
}
public object GetEditor(Type editorBaseType)
{
return null;
}
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{
return new EventDescriptorCollection(null);
}
public EventDescriptorCollection GetEvents()
{
return new EventDescriptorCollection(null);
}
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
PropertyDescriptorCollection properties = new PropertyDescriptorCollection(null);
PropertyInfo[] info = base.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
for (int i = 0; i < info.Length; i++)
{
properties.Add(new CustomPropertyDescriptor(info[i], this.IsReadOnly));
}
return properties;
}
public PropertyDescriptorCollection GetProperties()
{
return this.GetProperties(null);
}
public object GetPropertyOwner(PropertyDescriptor pd)
{
return this;
}
#endregion
internal virtual bool IsReadOnly
{
get
{
return !this.explorerNode.EditEnabled;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Danilo is the creator of
SmartRules, a Business Rules Engine. He is an industry consultant working primarily with companies interested in implementing dynamic rules programming concepts to add flexibility to their architectures on web, CE, and desktop platforms. He operates his own website,
Kontac, where you will find more information.
To contact Danilo, email him at danilo.mendez@gmail.com.