/// <summary> /// This is the only method that needs to be overridden as long as we /// provide implementations for the ResourceSet/ResourceReader/ResourceWriter /// </summary> /// <param name="culture"></param> /// <param name="createIfNotExists"></param> /// <param name="tryParents"></param> /// <returns></returns> protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents) { // retrieve cached instance - outside of lock for perf if (InternalResourceSets.ContainsKey(culture.Name)) { return(InternalResourceSets[culture.Name]); } lock (SyncLock) { // have to check again to ensure still not existing if (InternalResourceSets.ContainsKey(culture.Name)) { return(InternalResourceSets[culture.Name]); } // Otherwise create a new instance, load it and return it DbResourceSet rs = new DbResourceSet(ResourceSetName, culture, Configuration); // Add the resource set to the cached set InternalResourceSets.Add(culture.Name, rs); // And return an instance return(rs); } }
/// <summary> /// This is the only method that needs to be overridden as long as we /// provide implementations for the ResourceSet/ResourceReader/ResourceWriter /// </summary> /// <param name="culture"></param> /// <param name="createIfNotExists"></param> /// <param name="tryParents"></param> /// <returns></returns> protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents) { var resourceSets = this.InternalResourceSets; // retrieve cached instance - outside of lock for perf if (resourceSets.ContainsKey(culture.Name)) return resourceSets[culture.Name]; lock(SyncLock) { // have to check again to ensure still not existing if (resourceSets.ContainsKey(culture.Name)) return resourceSets[culture.Name]; // Otherwise create a new instance, load it and return it DbResourceSet rs = new DbResourceSet(BaseNameField, culture); // Add the resource set to the cached set resourceSets.Add(culture.Name, rs); // And return an instance return rs; } }