public GetResourceSet ( string cultureName, string resourceSet ) : IDictionary | ||
cultureName | string | name of the culture Id (de, de-de) to retrieve |
resourceSet | string | Name of the resource set to retrieve |
return | IDictionary |
/// <summary> /// This is the worker method responsible for actually retrieving resources from the resource /// store. This method goes out queries the database by asking for a specific ResourceSet and /// Culture and it returns a Hashtable (as IEnumerable) to use as a ResourceSet. /// /// The ResourceSet manages access to resources via IEnumerable access which is ultimately used /// to return resources to the front end. /// /// Resources are read once and cached into an internal Items field. A ResourceReader instance /// is specific to a ResourceSet and Culture combination so there should never be a need to /// reload this data, except when explicitly clearing the reader/resourceset (in which case /// Items can be set to null via ClearResources()). /// </summary> /// <returns>An IDictionaryEnumerator of the resources for this reader</returns> public IDictionaryEnumerator GetEnumerator() { if (this.Items != null) return this.Items.GetEnumerator(); lock (_SyncLock) { // Check again to ensure we still don't have items if (this.Items != null) return this.Items.GetEnumerator(); // DEPENDENCY HERE // Here's the only place we really access the database and return // a specific ResourceSet for a given ResourceSet Id and Culture DbResourceDataManager Manager = new DbResourceDataManager(); this.Items = Manager.GetResourceSet(this.cultureInfo.Name, this.baseNameField); return this.Items.GetEnumerator(); } }
/// <summary> /// Manages caching of the Resource Sets. Once loaded the values are loaded from the /// cache only. /// </summary> /// <param name="cultureName"></param> /// <returns></returns> private IDictionary GetResourceCache(string cultureName) { if (cultureName == null) cultureName = ""; if (_resourceCache == null) _resourceCache = new ListDictionary(); IDictionary Resources = _resourceCache[cultureName] as IDictionary; if (Resources == null) { // DEPENDENCY HERE (#1): Using DbResourceDataManager to retrieve resources // Use datamanager to retrieve the resource keys from the database DbResourceDataManager Data = new DbResourceDataManager(); lock (_SyncLock) { if (Resources == null) { if (_resourceCache.Contains(cultureName)) Resources = _resourceCache[cultureName] as IDictionary; else Resources = Data.GetResourceSet(cultureName as string, _ResourceSetName); _resourceCache[cultureName] = Resources; } } } return Resources; }
private void Load() { // RAS Modified: Read the full page path ie. /internationalization/test.aspx string ResourceSet = GetFullPagePath(); // Load IDictionary data using the DataManager (same code as provider) DbResourceDataManager Manager = new DbResourceDataManager(); this._reader = Manager.GetResourceSet("", ResourceSet); }