public object GetResource(string name, bool ignoreCase, bool isString, bool asSafe, bool cloneValue) { ResXResourceSet resx = resxResourceSet; ResourceSet compiled = compiledResourceSet; if (resx == null || compiled == null) { Throw.ObjectDisposedException(); } object result = resx.GetResourceInternal(name, ignoreCase, isString, asSafe, cloneValue); if (result != null) { return(result); } // if the null result is because it is explicitly stored, hiding the compiled value if (resx.ContainsResource(name, ignoreCase)) { return(null); } return(isString ? compiled.GetString(name, ignoreCase) : compiled.GetObject(name, ignoreCase)); }
public bool ContainsResource(string name, bool ignoreCase) { ResXResourceSet resx = resxResourceSet; ResourceSet compiled = compiledResourceSet; if (resx == null || compiled == null) { Throw.ObjectDisposedException(); } if (resx.ContainsResource(name, ignoreCase)) { return(true); } HashSet <string> binKeys = compiledKeys; if (binKeys == null) { // no foreach because that would evaluate (deserialize) the values, too binKeys = new HashSet <string>(); IDictionaryEnumerator compiledEnumerator = compiled.GetEnumerator(); while (compiledEnumerator.MoveNext()) { binKeys.Add(compiledEnumerator.Key.ToString()); } compiledKeys = binKeys; } if (binKeys.Contains(name)) { return(true); } if (!ignoreCase) { return(false); } HashSet <string> binKeysIgnoreCase = compiledKeysCaseInsensitive; if (binKeysIgnoreCase == null) { compiledKeysCaseInsensitive = binKeysIgnoreCase = new HashSet <string>(binKeys, StringComparer.OrdinalIgnoreCase); } return(binKeysIgnoreCase.Contains(name)); }