using System; using System.Collections; using System.Globalization; using System.IO; using System.Runtime.InteropServices; namespace System.Resources { /// Stores all the resources localized for one particular culture, ignoring all other cultures, including any fallback rules. // Token: 0x0200027D RID: 637 [ComVisible(true)] [Serializable] public class ResourceSet : IEnumerable, IDisposable { /// Initializes a new instance of the class with default properties. // Token: 0x06002074 RID: 8308 RVA: 0x00076A78 File Offset: 0x00074C78 protected ResourceSet() { this.Table = new Hashtable(); this.resources_read = true; } /// Creates a new instance of the class using the specified resource reader. /// The reader that will be used. /// The parameter is null. // Token: 0x06002075 RID: 8309 RVA: 0x00076A94 File Offset: 0x00074C94 public ResourceSet(IResourceReader reader) { if (reader == null) { throw new ArgumentNullException("reader"); } this.Table = new Hashtable(); this.Reader = reader; } /// Creates a new instance of the class using the system default that reads resources from the given stream. /// The of resources to be read. The stream should refer to an existing resources file. /// The is not readable. /// The parameter is null. // Token: 0x06002076 RID: 8310 RVA: 0x00076AC0 File Offset: 0x00074CC0 public ResourceSet(Stream stream) { this.Table = new Hashtable(); this.Reader = new ResourceReader(stream); } // Token: 0x06002077 RID: 8311 RVA: 0x00076AE0 File Offset: 0x00074CE0 internal ResourceSet(UnmanagedMemoryStream stream) { this.Table = new Hashtable(); this.Reader = new ResourceReader(stream); } /// Creates a new instance of the class using the system default that opens and reads resources from the given file. /// Resource file to read. /// The parameter is null. // Token: 0x06002078 RID: 8312 RVA: 0x00076B00 File Offset: 0x00074D00 public ResourceSet(string fileName) { this.Table = new Hashtable(); this.Reader = new ResourceReader(fileName); } /// Returns an object to avoid a race condition with Dispose. This member is not intended to be used directly from your code. /// An for the current object. // Token: 0x06002079 RID: 8313 RVA: 0x00076B20 File Offset: 0x00074D20 IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } /// Closes and releases any resources used by this . // Token: 0x0600207A RID: 8314 RVA: 0x00076B28 File Offset: 0x00074D28 public virtual void Close() { this.Dispose(); } /// Disposes of the resources (other than memory) used by the current instance of . // Token: 0x0600207B RID: 8315 RVA: 0x00076B30 File Offset: 0x00074D30 public void Dispose() { this.Dispose(true); GC.SuppressFinalize(this); } /// Releases resources (other than memory) associated with the current instance, closing internal managed objects if requested. /// Indicates whether the objects contained in the current instance should be explicitly closed. // Token: 0x0600207C RID: 8316 RVA: 0x00076B40 File Offset: 0x00074D40 protected virtual void Dispose(bool disposing) { if (disposing && this.Reader != null) { this.Reader.Close(); } this.Reader = null; this.Table = null; this.disposed = true; } /// Returns the preferred resource reader class for this kind of . /// Returns the for the preferred resource reader for this kind of . // Token: 0x0600207D RID: 8317 RVA: 0x00076B74 File Offset: 0x00074D74 public virtual Type GetDefaultReader() { return typeof(ResourceReader); } /// Returns the preferred resource writer class for this kind of . /// Returns the for the preferred resource writer for this kind of . // Token: 0x0600207E RID: 8318 RVA: 0x00076B80 File Offset: 0x00074D80 public virtual Type GetDefaultWriter() { return typeof(ResourceWriter); } /// Returns an that can iterate through the . /// An for this . /// The resource set has been closed or disposed. // Token: 0x0600207F RID: 8319 RVA: 0x00076B8C File Offset: 0x00074D8C [ComVisible(false)] public virtual IDictionaryEnumerator GetEnumerator() { if (this.disposed) { throw new ObjectDisposedException("ResourceSet is closed."); } this.ReadResources(); return this.Table.GetEnumerator(); } // Token: 0x06002080 RID: 8320 RVA: 0x00076BB8 File Offset: 0x00074DB8 private object GetObjectInternal(string name, bool ignoreCase) { if (name == null) { throw new ArgumentNullException("name"); } if (this.disposed) { throw new ObjectDisposedException("ResourceSet is closed."); } this.ReadResources(); object obj = this.Table[name]; if (obj != null) { return obj; } if (ignoreCase) { foreach (object obj2 in this.Table) { DictionaryEntry dictionaryEntry = (DictionaryEntry)obj2; string text = (string)dictionaryEntry.Key; if (string.Compare(text, name, true, CultureInfo.InvariantCulture) == 0) { return dictionaryEntry.Value; } } } return null; } /// Searches for a resource object with the specified name. /// The requested resource. /// Case-sensitive name of the resource to search for. /// The parameter is null. /// The object has been closed or disposed. // Token: 0x06002081 RID: 8321 RVA: 0x00076C9C File Offset: 0x00074E9C public virtual object GetObject(string name) { return this.GetObjectInternal(name, false); } /// Searches for a resource object with the specified name in a case-insensitive manner, if requested. /// The requested resource. /// Name of the resource to search for. /// Indicates whether the case of the specified name should be ignored. /// The parameter is null. /// The object has been closed or disposed. // Token: 0x06002082 RID: 8322 RVA: 0x00076CA8 File Offset: 0x00074EA8 public virtual object GetObject(string name, bool ignoreCase) { return this.GetObjectInternal(name, ignoreCase); } // Token: 0x06002083 RID: 8323 RVA: 0x00076CB4 File Offset: 0x00074EB4 private string GetStringInternal(string name, bool ignoreCase) { object @object = this.GetObject(name, ignoreCase); if (@object == null) { return null; } string text = @object as string; if (text == null) { throw new InvalidOperationException(string.Format("Resource '{0}' is not a String. Use GetObject instead.", name)); } return text; } /// Searches for a resource with the specified name. /// The value of a resource, if the value is a . /// Name of the resource to search for. /// The parameter is null. /// The object has been closed or disposed. // Token: 0x06002084 RID: 8324 RVA: 0x00076CF4 File Offset: 0x00074EF4 public virtual string GetString(string name) { return this.GetStringInternal(name, false); } /// Searches for a resource with the specified name in a case-insensitive manner, if requested. /// The value of a resource, if the value is a . /// Name of the resource to search for. /// Indicates whether the case of the case of the specified name should be ignored. /// The parameter is null. /// The object has been closed or disposed. // Token: 0x06002085 RID: 8325 RVA: 0x00076D00 File Offset: 0x00074F00 public virtual string GetString(string name, bool ignoreCase) { return this.GetStringInternal(name, ignoreCase); } /// Reads all the resources and stores them in a indicated in the property. // Token: 0x06002086 RID: 8326 RVA: 0x00076D0C File Offset: 0x00074F0C protected virtual void ReadResources() { if (this.resources_read) { return; } if (this.Reader == null) { throw new ObjectDisposedException("ResourceSet is closed."); } Hashtable table = this.Table; lock (table) { if (!this.resources_read) { IDictionaryEnumerator enumerator = this.Reader.GetEnumerator(); enumerator.Reset(); while (enumerator.MoveNext()) { this.Table.Add(enumerator.Key, enumerator.Value); } this.resources_read = true; } } } // Token: 0x06002087 RID: 8327 RVA: 0x00076DC0 File Offset: 0x00074FC0 internal UnmanagedMemoryStream GetStream(string name, bool ignoreCase) { if (this.Reader == null) { throw new ObjectDisposedException("ResourceSet is closed."); } IDictionaryEnumerator enumerator = this.Reader.GetEnumerator(); enumerator.Reset(); while (enumerator.MoveNext()) { if (string.Compare(name, (string)enumerator.Key, ignoreCase) == 0) { return ((ResourceReader.ResourceEnumerator)enumerator).ValueAsStream; } } return null; } /// Indicates the used to read the resources. // Token: 0x04000B7F RID: 2943 [NonSerialized] protected IResourceReader Reader; /// The in which the resources are stored. // Token: 0x04000B80 RID: 2944 protected Hashtable Table; // Token: 0x04000B81 RID: 2945 private bool resources_read; // Token: 0x04000B82 RID: 2946 [NonSerialized] private bool disposed; } }