[ComVisible (true)]
public class ResourceManager
{
+ static readonly object thisLock = new object ();
static Hashtable ResourceCache = new Hashtable ();
static Hashtable NonExistent = Hashtable.Synchronized (new Hashtable ());
public static readonly int HeaderVersionNumber = 1;
if (culture == null)
culture = CultureInfo.CurrentUICulture;
- lock (this) {
+ lock (thisLock) {
ResourceSet set = InternalGetResourceSet(culture, true, true);
object obj = null;
if (culture == null)
throw new ArgumentNullException ("culture");
- lock (this) {
+ lock (thisLock) {
return InternalGetResourceSet (culture, createIfNotExists, tryParents);
}
}
if (culture == null)
culture = CultureInfo.CurrentUICulture;
- lock (this) {
+ lock (thisLock) {
ResourceSet set = InternalGetResourceSet (culture, true, true);
string str = null;
throw new ArgumentNullException ("name");
if (culture == null)
culture = CultureInfo.CurrentUICulture;
- ResourceSet set = InternalGetResourceSet (culture, true, true);
+ ResourceSet set;
+
+ lock (thisLock) {
+ set = InternalGetResourceSet (culture, true, true);
+ }
+
return set.GetStream (name, ignoreCase);
}
if (culture == null)
throw new ArgumentNullException ("key"); // 'key' instead of 'culture' to make a test pass
- ResourceSet set;
+ ResourceSet set = null;
/* if we already have this resource set, return it */
set = (ResourceSet) ResourceSets [culture];
- if (set != null)
- return set;
+ if (set != null) {
+ try {
+ if (!set.IsDisposed)
+ return set;
+ } catch {
+ // ignore
+ }
+ ResourceSets.Remove (culture);
+ if (NonExistent.Contains (culture))
+ NonExistent.Remove (culture);
+ set = null;
+ }
+
if (NonExistent.Contains (culture))
return null;
[NonSerialized]
private bool disposed;
+ internal bool IsDisposed {
+ get { return disposed || Reader == null; }
+ }
+
// Constructors
protected ResourceSet ()
{
[ComVisible (false)]
public virtual IDictionaryEnumerator GetEnumerator ()
{
- if (disposed)
+ if (IsDisposed)
throw new ObjectDisposedException ("ResourceSet is closed.");
ReadResources ();
return Table.GetEnumerator();
{
if (name == null)
throw new ArgumentNullException ("name");
- if (disposed)
+ if (IsDisposed)
throw new ObjectDisposedException ("ResourceSet is closed.");
ReadResources ();
if (resources_read)
return;
- if (Reader == null)
+ if (IsDisposed)
throw new ObjectDisposedException ("ResourceSet is closed.");
lock (Table) {
if (resources_read)
internal UnmanagedMemoryStream GetStream (string name, bool ignoreCase)
{
- if (Reader == null)
+ if (IsDisposed)
throw new ObjectDisposedException ("ResourceSet is closed.");
IDictionaryEnumerator i = Reader.GetEnumerator();