System.ComponentModel.ComponentResourceManager.FillResources C# (CSharp) Method

FillResources() private method

Recursive routine that creates a resource hashtable populated with resources for culture and all parent cultures.
private FillResources ( CultureInfo culture, ResourceSet &resourceSet ) : object>.SortedList
culture System.Globalization.CultureInfo
resourceSet System.Resources.ResourceSet
return object>.SortedList
        private SortedList<string, object> FillResources(CultureInfo culture, out ResourceSet resourceSet)
        {
            SortedList<string, object> sd;
            ResourceSet parentResourceSet = null;

            // Traverse parents first, so we always replace more
            // specific culture values with less specific.
            //
            if (!culture.Equals(CultureInfo.InvariantCulture) && !culture.Equals(NeutralResourcesCulture))
            {
                sd = FillResources(culture.Parent, out parentResourceSet);
            }
            else
            {
                // We're at the bottom, so create the sorted dictionary
                // 
                if (IgnoreCase)
                {
                    sd = new SortedList<string, object>(StringComparer.OrdinalIgnoreCase);
                }
                else
                {
                    sd = new SortedList<string, object>(StringComparer.Ordinal);
                }
            }

            // Now walk culture's resource set.  Another thing we
            // do here is ask ResourceManager to traverse up the 
            // parent chain.  We do NOT want to do this because
            // we are trawling up the parent chain ourselves, but by
            // passing in true for the second parameter the resource
            // manager will cache the culture it did find, so when we 
            // do recurse all missing resources will be filled in
            // so we are very fast.  That's why we remember what our
            // parent resource set's instance was -- if they are the
            // same, we're looking at a cache we've already applied.
            //
            resourceSet = GetResourceSet(culture, true, true);
            if (resourceSet != null && !object.ReferenceEquals(resourceSet, parentResourceSet))
            {
                foreach (DictionaryEntry de in resourceSet)
                {
                    sd[(string)de.Key] = de.Value;
                }
            }

            return sd;
        }
    }