Exemple #1
0
 internal static ResourceManager GetResourceManager(
     Assembly assembly,
     string baseName)
 {
     using (ResourceManagerCache.tracer.TraceMethod())
     {
         if (assembly == null)
         {
             throw ResourceManagerCache.tracer.NewArgumentNullException(nameof(assembly));
         }
         if (string.IsNullOrEmpty(baseName))
         {
             throw ResourceManagerCache.tracer.NewArgumentException(nameof(baseName));
         }
         ResourceManager resourceManager = (ResourceManager)null;
         Dictionary <string, ResourceManager> dictionary1 = (Dictionary <string, ResourceManager>)null;
         lock (ResourceManagerCache.syncRoot)
         {
             if (ResourceManagerCache.resourceManagerCache.ContainsKey(assembly.Location))
             {
                 dictionary1 = ResourceManagerCache.resourceManagerCache[assembly.Location];
                 if (dictionary1 != null)
                 {
                     if (dictionary1.ContainsKey(baseName))
                     {
                         resourceManager = dictionary1[baseName];
                     }
                 }
             }
         }
         if (resourceManager == null)
         {
             ResourceManagerCache.tracer.WriteLine("Initializing new ResourceManager instance", new object[0]);
             ResourceManagerCache.tracer.WriteLine("Resource base name: {0}", (object)baseName);
             ResourceManagerCache.tracer.WriteLine("Resource assembly location: {0}", (object)assembly.Location);
             resourceManager = ResourceManagerCache.InitRMWithAssembly(baseName, assembly, (Type)null);
             if (dictionary1 != null)
             {
                 lock (ResourceManagerCache.syncRoot)
                     dictionary1[baseName] = resourceManager;
             }
             else
             {
                 Dictionary <string, ResourceManager> dictionary2 = new Dictionary <string, ResourceManager>();
                 dictionary2[baseName] = resourceManager;
                 lock (ResourceManagerCache.syncRoot)
                     ResourceManagerCache.resourceManagerCache[assembly.Location] = dictionary2;
             }
         }
         return(resourceManager);
     }
 }