DRMFSS.Shared.DBResourceProvider.GetObject C# (CSharp) Method

GetObject() public method

Retrieves a resource entry based on the specified culture and resource key. The resource type is based on this instance of the DBResourceProvider as passed to the constructor. To optimize performance, this function caches values in a dictionary per culture.
public GetObject ( string resourceKey, System culture ) : object
resourceKey string The resource key to find.
culture System The culture to search with.
return object
        public object GetObject(string resourceKey, System.Globalization.CultureInfo culture)
        {
            Debug.WriteLine(String.Format(CultureInfo.InvariantCulture, "DBResourceProvider.GetObject({0}, {1}) - type:{2}", resourceKey, culture, this.m_classKey));

            if (Disposed)
            {
                throw new ObjectDisposedException("DBResourceProvider object is already disposed.");
            }

            if (string.IsNullOrEmpty(resourceKey))
            {
                throw new ArgumentNullException("resourceKey");
            }

            if (culture == null)
            {
                culture = CultureInfo.CurrentUICulture;
            }

            string resourceValue = null;
            Dictionary<string, string> resCacheByCulture = null;
            // check the cache first
            // find the dictionary for this culture
            // check for the inner dictionary entry for this key
            //if (m_resourceCache.ContainsKey(culture.Name))
            //{
            //    resCacheByCulture = m_resourceCache[culture.Name];
            //    if (resCacheByCulture.ContainsKey(resourceKey))
            //    {
            //        resourceValue = resCacheByCulture[resourceKey];
            //    }
            //}

            // if not in the cache, go to the database
            if (resourceValue == null)
            {
                resourceValue = m_dalc.GetResourceByCultureAndKey(culture, resourceKey);

                // add this result to the cache
                // find the dictionary for this culture
                // add this key/value pair to the inner dictionary
                //lock (this)
                //{
                //    if (resCacheByCulture == null)
                //    {
                //        resCacheByCulture = new Dictionary<string, string>();
                //        m_resourceCache.Add(culture.Name, resCacheByCulture);
                //    }
                //    resCacheByCulture.Add(resourceKey, resourceValue);
                //}
            }
            return resourceValue;
        }