[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Resources ResourceMan
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Resources ResourceManager.cs,1.6,1.7 |
Date: |
Tue, 10 Dec 2002 19:46:01 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Resources
In directory subversions:/tmp/cvs-serv18618/runtime/System/Resources
Modified Files:
ResourceManager.cs
Log Message:
Attempt to load satellite assemblies for foreign language resources, before
falling back to the builtin English defaults.
Index: ResourceManager.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Resources/ResourceManager.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** ResourceManager.cs 17 Jun 2002 07:22:26 -0000 1.6
--- ResourceManager.cs 11 Dec 2002 00:45:59 -0000 1.7
***************
*** 41,44 ****
--- 41,45 ----
protected Assembly MainAssembly;
protected Hashtable ResourceSets;
+ private Hashtable notPresent;
private bool ignoreCase;
private Type resourceSetType;
***************
*** 51,54 ****
--- 52,56 ----
MainAssembly = null;
ResourceSets = new Hashtable();
+ notPresent = new Hashtable();
ignoreCase = false;
resourceSetType = null;
***************
*** 64,67 ****
--- 66,70 ----
MainAssembly = resourceSource.Assembly;
ResourceSets = new Hashtable();
+ notPresent = new Hashtable();
ignoreCase = false;
resourceSetType = typeof(BuiltinResourceSet);
***************
*** 81,84 ****
--- 84,88 ----
MainAssembly = assembly;
ResourceSets = new Hashtable();
+ notPresent = new Hashtable();
ignoreCase = false;
resourceSetType = typeof(BuiltinResourceSet);
***************
*** 99,102 ****
--- 103,107 ----
MainAssembly = assembly;
ResourceSets = new Hashtable();
+ notPresent = new Hashtable();
ignoreCase = false;
resourceDir = null;
***************
*** 122,125 ****
--- 127,131 ----
MainAssembly = null;
ResourceSets = new Hashtable();
+ notPresent = new Hashtable();
ignoreCase = false;
resourceSetType = usingResourceSet;
***************
*** 252,261 ****
lock(this)
{
! ResourceSet set = InternalGetResourceSet
! (culture, true, true);
! if(set != null)
{
! return set.GetString(name);
}
}
return name;
--- 258,280 ----
lock(this)
{
! // Scan up through the parent cultures
until we
! // find a string that matches the tag.
We do this
! // so that we can pick up the neutral
fallbacks if
! // language-specific versions are not
available.
! do
{
! ResourceSet set =
InternalGetResourceSet
! (culture, true, true);
! if(set != null)
! {
! return
set.GetString(name);
! }
!
if(culture.Equals(CultureInfo.InvariantCulture))
! {
! break;
! }
! culture = culture.Parent;
}
+ while(culture != null);
}
return name;
***************
*** 263,270 ****
// Release all cached resources.
- [TODO]
public virtual void ReleaseAllResources()
{
! // TODO
}
--- 282,297 ----
// Release all cached resources.
public virtual void ReleaseAllResources()
{
! lock(this)
! {
! IDictionaryEnumerator e =
ResourceSets.GetEnumerator();
! while(e.MoveNext())
! {
!
((ResourceSet)(e.Value)).Dispose();
! }
! ResourceSets = new Hashtable();
! notPresent = new Hashtable();
! }
}
***************
*** 315,318 ****
--- 342,353 ----
}
+ // If "notPresent" is set, then we know
that we looked
+ // for the culture previously and
didn't find it.
+ if(notPresent[current.Name] != null)
+ {
+ current = current.Parent;
+ continue;
+ }
+
// See if we have a cached resource set
for this culture.
set =
(ResourceSet)(ResourceSets[current.Name]);
***************
*** 331,334 ****
--- 366,370 ----
return set;
}
+ notPresent[current.Name] =
(Object)true;
}
***************
*** 357,361 ****
// Attempt to load a resource for this
culture.
! if(createIfNotExists)
{
set = AttemptLoad(current);
--- 393,397 ----
// Attempt to load a resource for this
culture.
! if(notPresent[current.Name] == null &&
createIfNotExists)
{
set = AttemptLoad(current);
***************
*** 365,368 ****
--- 401,405 ----
return set;
}
+ notPresent[current.Name] =
(Object)true;
}
}
***************
*** 375,379 ****
return set;
}
! if(createIfNotExists)
{
set = AttemptLoad(current);
--- 412,416 ----
return set;
}
! if(notPresent[current.Name] == null &&
createIfNotExists)
{
set = AttemptLoad(current);
***************
*** 383,386 ****
--- 420,424 ----
return set;
}
+ notPresent[current.Name] = (Object)true;
}
***************
*** 421,427 ****
{
Stream stream;
if(MainAssembly != null)
{
! // Try loading the resources from an
assembly.
stream =
MainAssembly.GetManifestResourceStream
(GetResourceFileName(culture));
--- 459,468 ----
{
Stream stream;
+ Assembly assembly;
+ int error;
+
if(MainAssembly != null)
{
! // Try loading the resources from the
main assembly.
stream =
MainAssembly.GetManifestResourceStream
(GetResourceFileName(culture));
***************
*** 429,432 ****
--- 470,493 ----
{
return
AttemptCreate(resourceSetType, stream);
+ }
+
+ // Try loading the resources from a
satellite assembly.
+ String path =
MainAssembly.GetSatellitePath
+ (culture.Name +
Path.DirectorySeparatorChar +
+ MainAssembly.FullName +
".resources.dll");
+ if(path != null)
+ {
+ error = 1;
+ assembly = Assembly.LoadFromFile
+ (path, out error,
MainAssembly);
+ if(assembly != null && error ==
0)
+ {
+ stream =
MainAssembly.GetManifestResourceStream
+
(GetResourceFileName(culture));
+ if(stream != null)
+ {
+ return
AttemptCreate(resourceSetType, stream);
+ }
+ }
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Resources ResourceManager.cs,1.6,1.7,
Rhys Weatherley <address@hidden> <=