Merge pull request #2707 from lambdageek/dev/monoerror-mono_image_load_module_dynamic
[mono.git] / mcs / class / corlib / System.Reflection / CustomAttributeNamedArgument.cs
index 9c462b58ffe25f1ad6351642547da4838a76c167..594c60a74a2ce03a65933cc3c713995fafea0aa0 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Author:
 //   Zoltan Varga (vargaz@gmail.com)
+//   Carlos Alberto Cortez (calberto.cortez@gmail.com)
 //
 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
 //
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 using System;
 using System.Runtime.InteropServices;
 
 namespace System.Reflection {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
+       [Serializable]
        public struct CustomAttributeNamedArgument {
+               CustomAttributeTypedArgument typedArgument;
+               MemberInfo memberInfo;
+               
+               public
+               CustomAttributeNamedArgument (MemberInfo memberInfo, object value)
+               {
+                       this.memberInfo = memberInfo;
+                       this.typedArgument = (CustomAttributeTypedArgument) value;
+               }
+               
+               public CustomAttributeNamedArgument (MemberInfo memberInfo, CustomAttributeTypedArgument typedArgument)
+               {
+                       this.memberInfo = memberInfo;
+                       this.typedArgument = typedArgument;
+               }
 
-               [MonoTODO]
                public MemberInfo MemberInfo {
                        get {
-                               throw new NotImplementedException ();
+                               return memberInfo;
                        }
                }
 
-               [MonoTODO]
                public CustomAttributeTypedArgument TypedValue {
                        get {
-                               throw new NotImplementedException ();
+                               return typedArgument;
                        }
                }
+
+               public bool IsField {
+                       get { return memberInfo.MemberType == MemberTypes.Field; }
+               }
+
+               public string MemberName {
+                       get { return memberInfo.Name; }
+               }
+
+               public override string ToString ()
+               {
+                       return memberInfo.Name + " = " + typedArgument.ToString ();
+               }
+
+               public override bool Equals (object obj)
+               {
+                       if (!(obj is CustomAttributeNamedArgument))
+                               return false;
+                       CustomAttributeNamedArgument other = (CustomAttributeNamedArgument) obj;
+                       return  other.memberInfo == memberInfo &&
+                               typedArgument.Equals (other.typedArgument);
+               }
+
+               public override int GetHashCode ()
+               {
+                       return (memberInfo.GetHashCode () << 16) + typedArgument.GetHashCode ();
+               }
+
+               public static bool operator == (CustomAttributeNamedArgument left, CustomAttributeNamedArgument right)
+               {
+                       return left.Equals (right);
+               }
+
+               public static bool operator != (CustomAttributeNamedArgument left, CustomAttributeNamedArgument right)
+               {
+                       return !left.Equals (right);
+               }
        }
 
 }
 
-#endif
-