//\r
\r
using System;\r
+using System.Globalization;\r
+\r
namespace System {\r
\r
+ [AttributeUsage(AttributeTargets.All)]\r
+ [Serializable]\r
public abstract class Attribute {\r
\r
protected Attribute ()\r
public virtual object TypeId {\r
get {\r
// Derived classes should override this default behaviour as appropriate\r
- return this.GetType();\r
+ return this.GetType ();\r
}\r
}\r
\r
- private static void CheckParameters(object element, Type attributeType)\r
+ private static void CheckParameters (object element, Type attribute_type)\r
{\r
// neither parameter is allowed to be null\r
if (null == element) \r
{\r
- throw new ArgumentNullException("element");\r
+ throw new ArgumentNullException ("element");\r
}\r
\r
- if (null == attributeType) \r
+ if (null == attribute_type) \r
{\r
- throw new ArgumentNullException("attributeType");\r
+ throw new ArgumentNullException ("attribute_type");\r
}\r
-\r
}\r
\r
- private static System.Attribute FindAttribute(object[] attributes)\r
+ private static System.Attribute FindAttribute (object[] attributes)\r
{\r
// if there exists more than one attribute of the given type, throw an exception\r
- if (attributes.Length > 1) \r
- {\r
- throw new System.Reflection.AmbiguousMatchException("<element> has more than one attribute of type <attributeType>");\r
+ if (attributes.Length > 1) {\r
+ throw new System.Reflection.AmbiguousMatchException (\r
+ Locale.GetText ("<element> has more than one attribute of type <attribute_type>"));\r
}\r
\r
if (attributes.Length < 1) \r
- {\r
- return (System.Attribute) null;\r
- }\r
+ return null;\r
\r
- // tested above for '> 1' and and '< 1', so only '== 1' is left, i.e. we found the attribute\r
+ // tested above for '> 1' and and '< 1', so only '== 1' is left,\r
+ // i.e. we found the attribute\r
+ \r
return (System.Attribute) attributes[0];\r
}\r
\r
- private static void CheckAncestry(Type attributeType)\r
+ private static void CheckAncestry (Type attribute_type)\r
{\r
- // attributeType must be derived from type System.Attribute\r
- Type t = typeof(System.Attribute);\r
- if (!attributeType.IsSubclassOf(t))\r
+ // attribute_type must be derived from type System.Attribute\r
+ Type t = typeof (System.Attribute);\r
+ \r
+ /* fixme: thgi does not work for target monolib2\r
+ if (!attribute_type.IsSubclassOf (t))\r
{\r
- throw new ArgumentException("Parameter is not a type derived from System.Attribute", "attributeType");\r
+ throw new ArgumentException ("Parameter is not a type derived from System.Attribute", "attribute_type");\r
}\r
+ */\r
}\r
\r
- public static Attribute GetCustomAttribute(System.Reflection.ParameterInfo element, Type attributeType){\r
- return GetCustomAttribute(element, attributeType, true);\r
+ public static Attribute GetCustomAttribute (System.Reflection.ParameterInfo element,\r
+ Type attribute_type)\r
+ {\r
+ return GetCustomAttribute (element, attribute_type, true);\r
}\r
\r
- public static Attribute GetCustomAttribute(System.Reflection.MemberInfo element, Type attributeType){\r
- return GetCustomAttribute(element, attributeType, true);\r
+ public static Attribute GetCustomAttribute (System.Reflection.MemberInfo element,\r
+ Type attribute_type)\r
+ {\r
+ return GetCustomAttribute (element, attribute_type, true);\r
}\r
\r
- public static Attribute GetCustomAttribute(System.Reflection.Assembly element, Type attributeType){ return GetCustomAttribute(element, attributeType, true);\r
+ public static Attribute GetCustomAttribute (System.Reflection.Assembly element,\r
+ Type attribute_type)\r
+ {\r
+ return GetCustomAttribute (element, attribute_type, true);\r
}\r
\r
- public static Attribute GetCustomAttribute(System.Reflection.Module element, Type attributeType){\r
- return GetCustomAttribute(element, attributeType, true);\r
+ public static Attribute GetCustomAttribute (System.Reflection.Module element,\r
+ Type attribute_type)\r
+ {\r
+ return GetCustomAttribute (element, attribute_type, true);\r
}\r
\r
- public static Attribute GetCustomAttribute(System.Reflection.Module element, Type attributeType, bool inherit){\r
+ public static Attribute GetCustomAttribute (System.Reflection.Module element,\r
+ Type attribute_type, bool inherit)\r
+ {\r
// neither parameter is allowed to be null\r
- CheckParameters(element, attributeType);\r
+ CheckParameters (element, attribute_type);\r
\r
- // attributeType must be derived from type System.Attribute\r
- CheckAncestry(attributeType);\r
+ // attribute_type must be derived from type System.Attribute\r
+ CheckAncestry (attribute_type);\r
\r
// Module inheritance hierarchies CAN NOT be searched for attributes, so the second\r
- // parameter of GetCustomAttributes() is INGNORED.\r
- object[] attributes = element.GetCustomAttributes(attributeType, inherit);\r
+ // parameter of GetCustomAttributes () is INGNORED.\r
+ object[] attributes = element.GetCustomAttributes (attribute_type, inherit);\r
\r
- return FindAttribute(attributes);\r
+ return FindAttribute (attributes);\r
}\r
\r
- public static Attribute GetCustomAttribute(System.Reflection.Assembly element, Type attributeType, bool inherit){\r
+ public static Attribute GetCustomAttribute (System.Reflection.Assembly element,\r
+ Type attribute_type, bool inherit)\r
+ {\r
// neither parameter is allowed to be null\r
- CheckParameters(element, attributeType);\r
+ CheckParameters (element, attribute_type);\r
\r
- // attributeType must be derived from type System.Attribute\r
- CheckAncestry(attributeType);\r
+ // attribute_type must be derived from type System.Attribute\r
+ CheckAncestry (attribute_type);\r
\r
// Assembly inheritance hierarchies CAN NOT be searched for attributes, so the second\r
- // parameter of GetCustomAttributes() is INGNORED.\r
- object[] attributes = element.GetCustomAttributes(attributeType, inherit);\r
+ // parameter of GetCustomAttributes () is INGNORED.\r
+ object[] attributes = element.GetCustomAttributes (attribute_type, inherit);\r
\r
- return FindAttribute(attributes);\r
+ return FindAttribute (attributes);\r
}\r
- public static Attribute GetCustomAttribute(System.Reflection.ParameterInfo element, Type attributeType, bool inherit){\r
+\r
+ public static Attribute GetCustomAttribute (System.Reflection.ParameterInfo element,\r
+ Type attribute_type, bool inherit)\r
+ {\r
// neither parameter is allowed to be null\r
- CheckParameters(element, attributeType);\r
+ CheckParameters (element, attribute_type);\r
\r
- // attributeType must be derived from type System.Attribute\r
- CheckAncestry(attributeType);\r
+ // attribute_type must be derived from type System.Attribute\r
+ CheckAncestry (attribute_type);\r
\r
// ParameterInfo inheritance hierarchies CAN NOT be searched for attributes, so the second\r
- // parameter of GetCustomAttributes() is INGNORED.\r
- object[] attributes = element.GetCustomAttributes(attributeType, inherit);\r
+ // parameter of GetCustomAttributes () is INGNORED.\r
+ object[] attributes = element.GetCustomAttributes (attribute_type, inherit);\r
\r
- return FindAttribute(attributes);\r
+ return FindAttribute (attributes);\r
}\r
- public static Attribute GetCustomAttribute(System.Reflection.MemberInfo element, Type attributeType, bool inherit){\r
+\r
+ public static Attribute GetCustomAttribute (System.Reflection.MemberInfo element,\r
+ Type attribute_type, bool inherit)\r
+ {\r
// neither parameter is allowed to be null\r
- CheckParameters(element, attributeType);\r
+ CheckParameters (element, attribute_type);\r
\r
- // attributeType must be derived from type System.Attribute\r
- CheckAncestry(attributeType);\r
+ // attribute_type must be derived from type System.Attribute\r
+ CheckAncestry (attribute_type);\r
\r
// MemberInfo inheritance hierarchies can be searched for attributes, so the second\r
- // parameter of GetCustomAttributes() is respected.\r
- object[] attributes = element.GetCustomAttributes(attributeType, inherit);\r
+ // parameter of GetCustomAttributes () is respected.\r
+ object[] attributes = element.GetCustomAttributes (attribute_type, inherit);\r
\r
- return FindAttribute(attributes);\r
+ return FindAttribute (attributes);\r
}\r
\r
- public static Attribute[] GetCustomAttributes(System.Reflection.Assembly element){\r
- return System.Attribute.GetCustomAttributes(element, true);\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.Assembly element)\r
+ {\r
+ return System.Attribute.GetCustomAttributes (element, true);\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.ParameterInfo element){\r
- return System.Attribute.GetCustomAttributes(element, true);\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.ParameterInfo element)\r
+ {\r
+ return System.Attribute.GetCustomAttributes (element, true);\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.MemberInfo element){\r
- return System.Attribute.GetCustomAttributes(element, true);\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.MemberInfo element){\r
+ return System.Attribute.GetCustomAttributes (element, true);\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.Module element){\r
- return System.Attribute.GetCustomAttributes(element, true);\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.Module element){\r
+ return System.Attribute.GetCustomAttributes (element, true);\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.Assembly element, Type attributeType){\r
- return System.Attribute.GetCustomAttributes(element, attributeType, true);\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.Assembly element,\r
+ Type attribute_type)\r
+ {\r
+ return System.Attribute.GetCustomAttributes (element, attribute_type, true);\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.Module element, Type attributeType){\r
- return System.Attribute.GetCustomAttributes(element, attributeType, true);\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.Module element,\r
+ Type attribute_type)\r
+ {\r
+ return System.Attribute.GetCustomAttributes (element, attribute_type, true);\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.ParameterInfo element, Type attributeType){\r
- return System.Attribute.GetCustomAttributes(element, attributeType, true);\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.ParameterInfo element,\r
+ Type attribute_type)\r
+ {\r
+ return System.Attribute.GetCustomAttributes (element, attribute_type, true);\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.MemberInfo element, Type attributeType)\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.MemberInfo element,\r
+ Type attribute_type)\r
{\r
- return System.Attribute.GetCustomAttributes(element, attributeType, true);\r
+ return System.Attribute.GetCustomAttributes (element, attribute_type, true);\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.Assembly element, Type attributeType, bool inherit)\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.Assembly element,\r
+ Type attribute_type, bool inherit)\r
{\r
// element parameter is not allowed to be null\r
- CheckParameters(element, attributeType);\r
+ CheckParameters (element, attribute_type);\r
\r
// make a properly typed array to return containing the custom attributes\r
- System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes(attributeType, inherit);\r
+ System.Attribute[] attributes;\r
+\r
+ attributes = (System.Attribute[]) element.GetCustomAttributes (\r
+ attribute_type, inherit);\r
\r
return attributes;\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.ParameterInfo element, Type attributeType, bool inherit){\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.ParameterInfo element,\r
+ Type attribute_type, bool inherit)\r
+ {\r
// element parameter is not allowed to be null\r
- CheckParameters(element, attributeType);\r
+ CheckParameters (element, attribute_type);\r
\r
// make a properly typed array to return containing the custom attributes\r
- System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes(attributeType, inherit);\r
+ System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes (\r
+ attribute_type, inherit);\r
\r
return attributes;\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.Module element, Type attributeType, bool inherit){\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.Module element,\r
+ Type attribute_type, bool inherit)\r
+ {\r
// element parameter is not allowed to be null\r
- CheckParameters(element, attributeType);\r
+ CheckParameters (element, attribute_type);\r
\r
// make a properly typed array to return containing the custom attributes\r
- System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes(attributeType, inherit);\r
+ System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes (\r
+ attribute_type, inherit);\r
\r
return attributes;\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.MemberInfo element, Type attributeType, bool inherit)\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.MemberInfo element,\r
+ Type attribute_type, bool inherit)\r
{\r
// element parameter is not allowed to be null\r
- CheckParameters(element, attributeType);\r
+ CheckParameters (element, attribute_type);\r
\r
// make a properly typed array to return containing the custom attributes\r
- System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes(attributeType, inherit);\r
+ System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes (\r
+ attribute_type, inherit);\r
\r
return attributes;\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.Module element, bool inherit)\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.Module element,\r
+ bool inherit)\r
{\r
// element parameter is not allowed to be null\r
- CheckParameters(element, typeof(System.Attribute));\r
+ CheckParameters (element, typeof (System.Attribute));\r
\r
// make a properly typed array to return containing the custom attributes\r
- System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes(inherit);\r
+ System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes (\r
+ inherit);\r
\r
return attributes;\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.Assembly element, bool inherit){\r
+ \r
+ public static Attribute[] GetCustomAttributes (System.Reflection.Assembly element,\r
+ bool inherit)\r
+ {\r
// element parameter is not allowed to be null\r
- CheckParameters(element, typeof(System.Attribute));\r
+ CheckParameters (element, typeof (System.Attribute));\r
\r
// make a properly typed array to return containing the custom attributes\r
- System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes(inherit);\r
+ System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes (\r
+ inherit);\r
\r
return attributes;\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.MemberInfo element, bool inherit){\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.MemberInfo element,\r
+ bool inherit)\r
+ {\r
// element parameter is not allowed to be null\r
- CheckParameters(element, typeof(System.Attribute));\r
+ CheckParameters (element, typeof (System.Attribute));\r
\r
// make a properly typed array to return containing the custom attributes\r
- System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes(inherit);\r
+ System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes (\r
+ inherit);\r
\r
return attributes;\r
}\r
- public static Attribute[] GetCustomAttributes(System.Reflection.ParameterInfo element, bool inherit){\r
+\r
+ public static Attribute[] GetCustomAttributes (System.Reflection.ParameterInfo element,\r
+ bool inherit)\r
+ {\r
// element parameter is not allowed to be null\r
- CheckParameters(element, typeof(System.Attribute));\r
+ CheckParameters (element, typeof (System.Attribute));\r
\r
// make a properly typed array to return containing the custom attributes\r
- System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes(inherit);\r
+ System.Attribute[] attributes = (System.Attribute[]) element.GetCustomAttributes (\r
+ inherit);\r
\r
return attributes;\r
}\r
\r
- public override int GetHashCode(){\r
- // TODO: Implement me\r
- return 0;\r
+ public override int GetHashCode ()\r
+ {\r
+ return ((Object) this).GetHashCode ();\r
}\r
\r
- public virtual bool IsDefaultAttribute(){\r
+ public virtual bool IsDefaultAttribute ()\r
+ {\r
// Derived classes should override this default behaviour as appropriate\r
return false;\r
}\r
\r
- public static bool IsDefined(System.Reflection.Module element, Type attributeType){\r
- return (System.Attribute.GetCustomAttributes(element, attributeType).Length > 0);\r
+ public static bool IsDefined (System.Reflection.Module element, Type attribute_type)\r
+ {\r
+ return (System.Attribute.GetCustomAttributes (element, attribute_type).Length > 0);\r
}\r
- public static bool IsDefined(System.Reflection.ParameterInfo element, Type attributeType){\r
- return (System.Attribute.GetCustomAttributes(element, attributeType).Length > 0);\r
+\r
+ public static bool IsDefined (System.Reflection.ParameterInfo element, Type attribute_type)\r
+ {\r
+ return (System.Attribute.GetCustomAttributes (element, attribute_type).Length > 0);\r
}\r
- public static bool IsDefined(System.Reflection.MemberInfo element, Type attributeType){\r
- return (System.Attribute.GetCustomAttributes(element, attributeType).Length > 0);\r
+\r
+ public static bool IsDefined (System.Reflection.MemberInfo element, Type attribute_type)\r
+ {\r
+ return (System.Attribute.GetCustomAttributes (element, attribute_type).Length > 0);\r
}\r
- public static bool IsDefined(System.Reflection.Assembly element, Type attributeType){\r
- return (System.Attribute.GetCustomAttributes(element, attributeType).Length > 0);\r
+\r
+ public static bool IsDefined (System.Reflection.Assembly element, Type attribute_type)\r
+ {\r
+ return (System.Attribute.GetCustomAttributes (element, attribute_type).Length > 0);\r
}\r
- public static bool IsDefined(System.Reflection.MemberInfo element, Type attributeType, bool inherit){\r
- return (System.Attribute.GetCustomAttributes(element, attributeType, inherit).Length > 0);\r
+\r
+ public static bool IsDefined (System.Reflection.MemberInfo element, Type attribute_type,\r
+ bool inherit)\r
+ {\r
+ return (System.Attribute.GetCustomAttributes (\r
+ element, attribute_type, inherit).Length > 0);\r
}\r
- public static bool IsDefined(System.Reflection.Assembly element, Type attributeType, bool inherit){\r
- return (System.Attribute.GetCustomAttributes(element, attributeType, inherit).Length > 0);\r
+\r
+ public static bool IsDefined (System.Reflection.Assembly element, Type attribute_type,\r
+ bool inherit)\r
+ {\r
+ return (System.Attribute.GetCustomAttributes (\r
+ element, attribute_type, inherit).Length > 0);\r
}\r
- public static bool IsDefined(System.Reflection.Module element, Type attributeType, bool inherit){\r
- return (System.Attribute.GetCustomAttributes(element, attributeType, inherit).Length > 0);\r
+\r
+ public static bool IsDefined (System.Reflection.Module element, Type attribute_type,\r
+ bool inherit)\r
+ {\r
+ return (System.Attribute.GetCustomAttributes (\r
+ element, attribute_type, inherit).Length > 0);\r
}\r
- public static bool IsDefined(System.Reflection.ParameterInfo element, Type attributeType, bool inherit){\r
- return (System.Attribute.GetCustomAttributes(element, attributeType, inherit).Length > 0);\r
+\r
+ public static bool IsDefined (System.Reflection.ParameterInfo element,\r
+ Type attribute_type, bool inherit)\r
+ {\r
+ return (System.Attribute.GetCustomAttributes (\r
+ element, attribute_type, inherit).Length > 0);\r
}\r
\r
- public virtual bool Match(object obj){\r
- // default action is the same as Equals. Derived classes should override as appropriate\r
- return this.Equals(obj);\r
+ public virtual bool Match (object obj)\r
+ {\r
+ // default action is the same as Equals.\r
+ // Derived classes should override as appropriate\r
+ \r
+ return this.Equals (obj);\r
}\r
\r
- }\r
+ public override bool Equals (object obj)\r
+ {\r
+ if (obj == null || !(obj is Attribute))\r
+ return false;\r
\r
+ return ((Attribute) obj) == this;\r
+ }\r
+ }\r
}\r