[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/I18N/Common Manager.cs,1.4,1.5
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/I18N/Common Manager.cs,1.4,1.5 |
Date: |
Thu, 14 Nov 2002 01:29:07 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/I18N/Common
In directory subversions:/tmp/cvs-serv29373/I18N/Common
Modified Files:
Manager.cs
Log Message:
Implement the "GetCultures" API in the I18N manager.
Index: Manager.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/I18N/Common/Manager.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** Manager.cs 9 Aug 2002 00:42:15 -0000 1.4
--- Manager.cs 14 Nov 2002 06:29:03 -0000 1.5
***************
*** 114,118 ****
// Get a specific culture by identifier. Returns NULL
// if the culture information is not available.
! public CultureInfo GetCulture(int culture, bool useUserOverride)
{
// Create the hex version of the culture
identifier.
--- 114,118 ----
// Get a specific culture by identifier. Returns NULL
// if the culture information is not available.
! public _I18NCultureHandler GetCulture(int culture, bool useUserOverride)
{
// Create the hex version of the culture
identifier.
***************
*** 130,144 ****
if(obj != null)
{
! return (obj as CultureInfo);
}
}
// Look for the generic non-override culture.
! return (Instantiate("CID" + name) as
CultureInfo);
}
// Get a specific culture by name. Returns NULL if the
// culture informaion is not available.
! public CultureInfo GetCulture(String name, bool useUserOverride)
{
// Validate the parameter.
--- 130,144 ----
if(obj != null)
{
! return (obj as
_I18NCultureHandler);
}
}
// Look for the generic non-override culture.
! return (Instantiate("CID" + name) as
_I18NCultureHandler);
}
// Get a specific culture by name. Returns NULL if the
// culture informaion is not available.
! public _I18NCultureHandler GetCulture(String name, bool useUserOverride)
{
// Validate the parameter.
***************
*** 157,166 ****
if(obj != null)
{
! return (obj as CultureInfo);
}
}
// Look for the generic non-override culture.
! return (Instantiate("CN" + name.ToString()) as
CultureInfo);
}
--- 157,262 ----
if(obj != null)
{
! return (obj as
_I18NCultureHandler);
}
}
// Look for the generic non-override culture.
! return (Instantiate("CN" + name.ToString())
! as _I18NCultureHandler);
! }
!
! // Convert a culture identifier from hex.
! private static int FromHex(String name, int index)
! {
! int num = 0;
! char ch;
! while(index < name.Length)
! {
! ch = name[index++];
! if(ch >= '0' && ch <= '9')
! {
! num = num * 16 + (int)(ch -
'0');
! }
! else if(ch >= 'A' && ch <= 'F')
! {
! num = num * 16 + (int)(ch - 'A'
+ 10);
! }
! else if(ch >= 'a' && ch <= 'f')
! {
! num = num * 16 + (int)(ch - 'a'
+ 10);
! }
! }
! return num;
! }
!
! // Determine if a handler name matches the "GetCultures" requirements.
! private static bool CultureMatch(String name, CultureTypes types)
! {
! if(name.Length > 3 &&
! name[0] == 'C' && name[1] == 'I' &&
! name[2] == 'D' && name[3] != 'O')
! {
! int num = FromHex(name, 3);
! if((num & 0x03FF) == 0)
! {
! // This is a neutral culture.
! if((types &
CultureTypes.NeutralCultures) != 0)
! {
! return true;
! }
! }
! else
! {
! // This is a specific culture.
! if((types &
CultureTypes.SpecificCultures) != 0)
! {
! return true;
! }
! }
! }
! return false;
! }
!
! // Get an array of all cultures in the system.
! public CultureInfo[] GetCultures(CultureTypes types)
! {
! // Count the number of culture handlers in the
system.
! int count = 0;
! if((types & CultureTypes.NeutralCultures) != 0)
! {
! ++count;
! }
! IDictionaryEnumerator e =
handlers.GetEnumerator();
! String name;
! int num;
! while(e.MoveNext())
! {
! name = (String)(e.Key);
! if(CultureMatch(name, types))
! {
! ++count;
! }
! }
!
! // Build the list of cultures.
! CultureInfo[] cultures = new CultureInfo
[count];
! count = 0;
! if((types & CultureTypes.NeutralCultures) != 0)
! {
! cultures[count++] =
CultureInfo.InvariantCulture;
! }
! e.Reset();
! while(e.MoveNext())
! {
! name = (String)(e.Key);
! if(CultureMatch(name, types))
! {
! cultures[count++] =
! new
CultureInfo(FromHex(name, 3));
! }
! }
!
! // Return the culture list to the caller.
! return cultures;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/I18N/Common Manager.cs,1.4,1.5,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.441,1.442
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnet/samples I18N.dll,1.16,1.17 mscorlib.dll,1.85,1.86
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.441,1.442
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnet/samples I18N.dll,1.16,1.17 mscorlib.dll,1.85,1.86
- Index(es):