Esempio n. 1
0
            public override bool Equals(object obj)
            {
                if (!(obj is ResourceManagerCacheKey))
                {
                    return(false);
                }
                ResourceManagerCacheKey key = (ResourceManagerCacheKey)obj;

                return(key._asm == _asm && _name.Equals(key._name, StringComparison.Ordinal));
            }
        ResourceManager GetResourceManager()
        {
            string   path;
            Assembly asm;

            if (isGlobal)
            {
                asm  = HttpContext.AppGlobalResourcesAssembly;
                path = resource;
            }
            else
            {
                asm  = GetLocalResourcesAssembly();
                path = Path.GetFileName(resource);

                if (String.IsNullOrEmpty(path))
                {
                    return(null);
                }
            }

            if (asm == null)
            {
                return(null);
            }

            ResourceManager rm;

            try
            {
                if (resourceManagerCache == null)
                {
                    resourceManagerCache = new Dictionary <ResourceManagerCacheKey, ResourceManager> ();
                }

                ResourceManagerCacheKey key = new ResourceManagerCacheKey(path, asm);
                if (!resourceManagerCache.TryGetValue(key, out rm))
                {
                    rm            = new ResourceManager(path, asm);
                    rm.IgnoreCase = true;
                    resourceManagerCache.Add(key, rm);
                }

                return(rm);
            }
            catch (MissingManifestResourceException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new HttpException("Failed to retrieve the specified global resource object.", ex);
            }
        }
Esempio n. 3
0
		ResourceManager GetResourceManager ()
		{
			string path;
			Assembly asm;

			if (isGlobal) {
				asm = HttpContext.AppGlobalResourcesAssembly;
				path = resource;
			} else {
				asm = GetLocalResourcesAssembly ();
				path = Path.GetFileName (resource);

				if (String.IsNullOrEmpty (path))
					return null;
			}

			if (asm == null)
				return null;
			
			ResourceManager rm;
			try {
				if (resourceManagerCache == null)
					resourceManagerCache = new Dictionary <ResourceManagerCacheKey, ResourceManager> ();
				
				ResourceManagerCacheKey key = new ResourceManagerCacheKey (path, asm);
				if (!resourceManagerCache.TryGetValue (key, out rm)) {
					rm = new ResourceManager (path, asm);
					rm.IgnoreCase = true;
					resourceManagerCache.Add (key, rm);
				}
				
				return rm;
			} catch (MissingManifestResourceException) {
				throw;
			} catch (Exception ex) {
				throw new HttpException ("Failed to retrieve the specified global resource object.", ex);
			}
		}