dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/System/Collections/Specialized NameOb


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System/Collections/Specialized NameObjectCollectionBase.cs,1.2,1.3
Date: Thu, 28 Nov 2002 22:28:32 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/System/Collections/Specialized
In directory subversions:/tmp/cvs-serv16400/System/Collections/Specialized

Modified Files:
        NameObjectCollectionBase.cs 
Log Message:


Modifications to support the ECMA-compatible compilation mode.


Index: NameObjectCollectionBase.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System/Collections/Specialized/NameObjectCollectionBase.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** NameObjectCollectionBase.cs 19 Nov 2002 05:04:38 -0000      1.2
--- NameObjectCollectionBase.cs 29 Nov 2002 03:28:30 -0000      1.3
***************
*** 24,27 ****
--- 24,28 ----
  
  using System;
+ using System.Globalization;
  using System.Collections;
  using System.Runtime.Serialization;
***************
*** 529,532 ****
--- 530,642 ----
  
        }; // class KeysEnumerator
+ 
+ #if ECMA_COMPAT
+ 
+       // Local copy of "System.Collections.CaseInsenstiveHashCodeProvider"
+       // for use in ECMA-compatbile systems.
+       private class CaseInsensitiveHashCodeProvider : IHashCodeProvider
+       {
+               private static readonly CaseInsensitiveHashCodeProvider
+                       defaultProvider = new CaseInsensitiveHashCodeProvider();
+ 
+               // Internal state.
+               private TextInfo info;
+ 
+               // Get the default comparer instance.
+               public static CaseInsensitiveHashCodeProvider Default
+                               {
+                                       get
+                                       {
+                                               return defaultProvider;
+                                       }
+                               }
+ 
+               // Constructors.
+               public CaseInsensitiveHashCodeProvider()
+                               {
+                                       info = 
CultureInfo.CurrentCulture.TextInfo;
+                               }
+               public CaseInsensitiveHashCodeProvider(CultureInfo culture)
+                               {
+                                       if(culture == null)
+                                       {
+                                               throw new 
ArgumentNullException("culture");
+                                       }
+                                       info = culture.TextInfo;
+                               }
+ 
+               // Implement the IHashCodeProvider interface.
+               public int GetHashCode(Object obj)
+                               {
+                                       String str = (obj as String);
+                                       if(str != null)
+                                       {
+                                               return 
info.ToLower(str).GetHashCode();
+                                       }
+                                       else if(obj != null)
+                                       {
+                                               return obj.GetHashCode();
+                                       }
+                                       else
+                                       {
+                                               throw new 
ArgumentNullException("obj");
+                                       }
+                               }
+ 
+       }; // class CaseInsensitiveHashCodeProvider
+ 
+       // Local copy of "System.Collections.CaseInsenstiveComparer"
+       // for use in ECMA-compatbile systems.
+       private class CaseInsensitiveComparer : IComparer
+       {
+               // The default case insensitive comparer instance.
+               private static readonly CaseInsensitiveComparer defaultComparer 
=
+                       new CaseInsensitiveComparer();
+       
+               // Internal state.
+               private CompareInfo compare;
+ 
+               // Get the default comparer instance.
+               public static CaseInsensitiveComparer Default
+                               {
+                                       get
+                                       {
+                                               return defaultComparer;
+                                       }
+                               }
+ 
+               // Constructors.
+               public CaseInsensitiveComparer()
+                               {
+                                       compare = 
CultureInfo.CurrentCulture.CompareInfo;
+                               }
+               public CaseInsensitiveComparer(CultureInfo culture)
+                               {
+                                       if(culture == null)
+                                       {
+                                               throw new 
ArgumentNullException("culture");
+                                       }
+                                       compare = culture.CompareInfo;
+                               }
+ 
+               // Implement the IComparer interface.
+               public int Compare(Object a, Object b)
+                               {
+                                       String stra = (a as String);
+                                       String strb = (b as String);
+                                       if(stra != null && strb != null)
+                                       {
+                                               return compare.Compare
+                                                       (stra, strb, 
CompareOptions.IgnoreCase);
+                                       }
+                                       else
+                                       {
+                                               return 
Comparer.Default.Compare(a, b);
+                                       }
+                               }
+ 
+       }; // class CaseInsensitiveComparer
+ 
+ #endif // ECMA_COMPAT
  
  }; // class NameObjectCollectionBase





reply via email to

[Prev in Thread] Current Thread [Next in Thread]