New tests.
[mono.git] / mcs / class / corlib / System.Security.Policy / HashMembershipCondition.cs
index cfa7ca7fc9e7a8670905dff1ee7ce6c0b243a1a7..6918f250f85c6ba3b6e522512d6eface402663fa 100644 (file)
@@ -1,12 +1,12 @@
 //
-// System.Security.Policy.HashMembershipCondition
+// System.Security.Policy.HashMembershipCondition.cs
 //
 // Authors:
 //     Jackson Harper (Jackson@LatitudeGeo.com)
 //     Sebastien Pouliot  <sebastien@ximian.com>
 //
 // (C) 2002 Jackson Harper, All rights reserved
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !MOONLIGHT
+
 using System.Collections;
 using System.Globalization;
 using System.Reflection;
+using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
 using System.Security.Cryptography;
 
@@ -39,11 +42,8 @@ using Mono.Security.Cryptography;
 namespace System.Security.Policy {
 
        [Serializable]
-#if NET_2_0
+       [ComVisible (true)]
        public sealed class HashMembershipCondition : IMembershipCondition, IDeserializationCallback, ISerializable {
-#else
-       public sealed class HashMembershipCondition : IMembershipCondition {
-#endif
                private readonly int version = 1;
 
                private HashAlgorithm hash_algorithm;
@@ -54,15 +54,15 @@ namespace System.Security.Policy {
                {
                }
 
-               public HashMembershipCondition (HashAlgorithm hash_algorithm, byte[] hash_value)
+               public HashMembershipCondition (HashAlgorithm hashAlg, byte[] value)
                {
-                       if (hash_algorithm == null)
-                               throw new ArgumentNullException ("hash_algorithm");
-                       if (hash_value == null)
-                               throw new ArgumentNullException ("hash_value");
+                       if (hashAlg == null)
+                               throw new ArgumentNullException ("hashAlg");
+                       if (value == null)
+                               throw new ArgumentNullException ("value");
                                
-                       this.hash_algorithm = hash_algorithm;
-                       this.hash_value = (byte[]) hash_value.Clone ();
+                       this.hash_algorithm = hashAlg;
+                       this.hash_value = (byte[]) value.Clone ();
                }
 
                //
@@ -123,12 +123,10 @@ namespace System.Security.Policy {
 
                public override bool Equals (object o)
                {
-                       HashMembershipCondition other;
-                       if (!(o is HashMembershipCondition))
+                       HashMembershipCondition other = (o as HashMembershipCondition);
+                       if (other == null)
                                return false;
 
-                       other = (HashMembershipCondition)o;
-                       
                        return ((other.HashAlgorithm == hash_algorithm) &&
                                Compare (hash_value, other.hash_value));
                }
@@ -146,9 +144,9 @@ namespace System.Security.Policy {
                        return se;
                }
 
-               public void FromXml (SecurityElement element)
+               public void FromXml (SecurityElement e)
                {
-                       FromXml (element, null);
+                       FromXml (e, null);
                }
                
                public void FromXml (SecurityElement e, PolicyLevel level)
@@ -197,7 +195,6 @@ namespace System.Security.Policy {
                        return true;
                }
 
-#if NET_2_0
                [MonoTODO ("fx 2.0")]
                void IDeserializationCallback.OnDeserialization (object sender)
                {
@@ -207,7 +204,8 @@ namespace System.Security.Policy {
                void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context) 
                {
                }
-#endif
        }
 }
 
+#endif
+