// (C) 2003 Andreas Nahr
//
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System;
+using System.Collections;
using System.Reflection;
using System.Runtime.InteropServices;
{
private string name;
- private string displayName;
private Attribute [] attrs;
private AttributeCollection attrCollection;
protected MemberDescriptor (string name, Attribute [] attrs)
{
this.name = name;
- this.displayName = name;
this.attrs = attrs;
}
protected MemberDescriptor (MemberDescriptor reference, Attribute [] attrs)
{
name = reference.name;
- this.displayName = name;
this.attrs = attrs;
}
protected MemberDescriptor (string name)
{
this.name = name;
- this.displayName = name;
}
protected MemberDescriptor (MemberDescriptor reference)
{
name = reference.name;
- this.displayName = name;
- attrs = reference.attrs;
+ attrs = reference.AttributeArray;
}
protected virtual Attribute [] AttributeArray
{
get
{
+ if (attrs == null)
+ {
+ ArrayList list = new ArrayList ();
+ FillAttributes (list);
+
+ ArrayList filtered = new ArrayList ();
+ foreach (Attribute at in list) {
+ bool found = false;
+ for (int n=0; n<filtered.Count && !found; n++)
+ found = (filtered[n].GetType() == at.GetType ());
+ if (!found)
+ filtered.Add (at);
+ }
+ attrs = (Attribute[]) filtered.ToArray (typeof(Attribute));
+ }
+
return attrs;
}
}
}
- [MonoTODO]
protected virtual void FillAttributes(System.Collections.IList attributeList)
{
- // LAMESPEC/FIXME - I don't think this is correct, but didn't really understand
- // what this sub is good for
- attributeList = this.attrs;
- return;
+ // to be overriden
}
public virtual AttributeCollection Attributes
protected virtual AttributeCollection CreateAttributeCollection()
{
- return new AttributeCollection (attrs);
+ return new AttributeCollection (AttributeArray);
}
public virtual string Category
{
get
{
- foreach (Attribute attr in attrs)
+ foreach (Attribute attr in AttributeArray)
{
if (attr is DescriptionAttribute)
return ((DescriptionAttribute) attr).Description;
{
get
{
- foreach (Attribute attr in attrs)
+ foreach (Attribute attr in AttributeArray)
{
if (attr is DesignOnlyAttribute)
return ((DesignOnlyAttribute) attr).IsDesignOnly;
{
get
{
- return displayName;
+ return name;
}
}
{
get
{
- foreach (Attribute attr in attrs)
+ foreach (Attribute attr in AttributeArray)
{
if (attr is BrowsableAttribute)
return ((BrowsableAttribute) attr).Browsable;
public override int GetHashCode()
{
- return name.GetHashCode ();
+ return base.GetHashCode ();
}
- [MonoTODO ("Probably not correctly implemented (too harsh?)")]
public override bool Equals(object obj)
{
- if (!(obj is MemberDescriptor))
- return false;
- if (obj == this)
- return true;
- return (((MemberDescriptor) obj).AttributeArray == attrs) &&
- (((MemberDescriptor) obj).Attributes == attrCollection) &&
- (((MemberDescriptor) obj).DisplayName == displayName) &&
- (((MemberDescriptor) obj).Name == name);
+ MemberDescriptor other = obj as MemberDescriptor;
+ if (other == null) return false;
+
+ return other.name == name;
}
protected static ISite GetSite(object component)
protected static object GetInvokee(Type componentClass, object component)
{
// FIXME WHAT should that do???
- throw new NotImplementedException ();
+
+ // Lluis: Checked with VS.NET and it always return the component, even if
+ // it has its own designer set with DesignerAttribute. So, no idea
+ // what this should do.
+ return component;
}
protected static MethodInfo FindMethod(Type componentClass, string name,