protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents) { ResourceSet resourceSet = (ResourceSet)ResourceSets[culture]; if (resourceSet == null) { // Lazy-load default language (without caring about duplicate assignment in race conditions, no harm done); if (neutralResourcesCulture == null) { neutralResourcesCulture = GetNeutralResourcesLanguage(MainAssembly); } // If we're asking for the default language, then ask for the invariant (non-specific) resources. if (neutralResourcesCulture.Equals(culture)) { culture = CultureInfo.InvariantCulture; } string resourceFileName = GetResourceFileName(culture); Stream store = MainAssembly.GetManifestResourceStream(contextTypeInfo, resourceFileName); // If we found the appropriate resources in the local assembly... if (store != null) { resourceSet = new ResourceSet(store); // Save for later. AddResourceSet(ResourceSets, culture, ref resourceSet); } else { resourceSet = base.InternalGetResourceSet(culture, createIfNotExists, tryParents); } } return resourceSet; }
public void Init() { // Determine if the Preset settings files exist for the routine // // This has been changed so that the XML files are now embedded resources // var presetResourceSet = new ResourceSet( Assembly.GetExecutingAssembly().GetManifestResourceStream("Paws.Properties.Resources.resources")); // Determine if the Preset settings files exist for the current character // var characterSettingsDirectory = Path.Combine(CharacterSettingsDirectory, "Paws"); if (!Directory.Exists(characterSettingsDirectory)) { Directory.CreateDirectory(characterSettingsDirectory); Log.Diagnostics("Character Settings Directory Established... generating default presets."); var resourceCount = 0; foreach (DictionaryEntry entry in presetResourceSet) { using ( var streamWriter = new StreamWriter( Path.Combine(characterSettingsDirectory, entry.Key.ToString().Replace("_", " ") + ".xml"), false)) { streamWriter.Write(entry.Value); resourceCount++; } } Log.Diagnostics(string.Format("...Finished generating {0} preset files", resourceCount)); } }
protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents) { ResourceSet rs = (ResourceSet)this.ResourceSets[culture]; if (rs == null) { Stream store = null; string resourceFileName = null; //lazy-load default language; if (this._neutralResourcesCulture == null) { this._neutralResourcesCulture = GetNeutralResourcesLanguage(this.MainAssembly); } //if we're asking for the default language, then ask for the invaliant (non-specific) resources. if (_neutralResourcesCulture.Equals(culture)) culture = CultureInfo.InvariantCulture; resourceFileName = GetResourceFileName(culture); store = this.MainAssembly.GetManifestResourceStream(this._contextTypeInfo, resourceFileName); //If we found the appropriate resources in the local assembly if (store != null) { rs = new ResourceSet(store); //save for later. AddResourceSet(this.ResourceSets, culture, ref rs); } else { rs = base.InternalGetResourceSet(culture, createIfNotExists, tryParents); } } return rs; }
public static Dictionary<String, Bitmap> CreateIconSetBitmaps(ResourceSet resSet, Boolean invert) { Dictionary<String, Bitmap> icons = new Dictionary<String, Bitmap>(); if (resSet != null) { foreach (System.Collections.DictionaryEntry e in resSet) { if (e.Key is String && e.Value is Bitmap) { Bitmap b = (Bitmap)e.Value; if (invert) { BitmapProcessing.Desaturate(b); BitmapProcessing.Invert(b); BitmapProcessing.AdjustBrightness(b, 101); } Bitmap b_hidden = new Bitmap(b); BitmapProcessing.AdjustOpacity(b_hidden, 100); Bitmap b_filtered = new Bitmap(b); BitmapProcessing.AdjustOpacity(b_filtered, Outliner.Controls.Tree.TreeNode.FilteredNodeOpacity); icons.Add((String)e.Key, b); icons.Add((String)e.Key + "_hidden", b_hidden); icons.Add((String)e.Key + "_filtered", b_filtered); } } } return icons; }
private static void AddResources(Dictionary<String, String> resources, ResourceManager resourceManager, ResourceSet neutralSet) { foreach (DictionaryEntry res in neutralSet) { string key = (string)res.Key; string value = resourceManager.GetObject(key) as string; if (value != null) { resources[key] = value; } } }
private static IEnumerable<DictionaryEntry> ConvertResourceSetToDictionaryEntries( ResourceSet resourceSet ) { var dictionaryEntries = new List<DictionaryEntry>(); foreach ( DictionaryEntry entry in resourceSet ) { dictionaryEntries.Add( entry ); } return dictionaryEntries; }
protected override void BeforeLocalizeType(Type controlType) { if (this.FIniSource != null) { this.ResourceSet = new IniResourceSet(this.FIniSource, controlType); } else if (this.FIniPath != null) { this.ResourceSet = new IniResourceSet(this.FIniPath, controlType); } }
public void Dispose() { if (this.IconPack != null) { this.IconPack.Dispose(); } this.IconPack = null; this.DefaultIconMap = null; this.VolumeTypeMap = null; this.DefaultIconSize = null; this.IconCache = null; }
public IconPackImageProvider(string iconPackPath) { this.IconPack = new ResourceSet(iconPackPath); foreach (DefaultIcon icon in Enum.GetValues(typeof(DefaultIcon))) { this.DefaultIconMap.Add(icon, string.Intern("DefaultIcon." + icon.ToString())); } foreach (VolumeType type in Enum.GetValues(typeof(VolumeType))) { this.VolumeTypeMap.Add(type, string.Intern("VolumeType." + type.ToString())); } }
private ICollection<KeyValuePair<string, object>> GetTextResourceContent(ResourceSet set, string lang) { var resourceDictionary = set.Cast<DictionaryEntry>() .ToDictionary(r => r.Key.ToString(), r => r.Value.ToString()); var content = (ICollection<KeyValuePair<string, object>>)new ExpandoObject(); foreach (var item in resourceDictionary) { content.Add(new KeyValuePair<string, object>(item.Key, item.Value)); } return content; }
private void Form1_Load(object sender, EventArgs e) { strs = new ArrayList(); rs = Properties.Resources.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true); foreach (DictionaryEntry entry in rs) { if (entry.Key.ToString().Contains("_")) continue; strs.Add(entry.Key); } strs.Sort(); foreach(string s in strs) comboBox1.Items.Add(s); }
/// <summary> /// This method will return a resource set based on a Culture set by application. /// </summary> /// <param name="culture"></param> /// <param name="createIfNotExists"></param> /// <param name="tryParents"></param> /// <returns>ResourceSet</returns> protected override ResourceSet InternalGetResourceSet(System.Globalization.CultureInfo culture, bool createIfNotExists, bool tryParents) { ResourceSet rs = null; lock (this.cultureResourceSetDictionary) { if (false == this.cultureResourceSetDictionary.TryGetValue(culture.Name, out rs)) { rs = new ResourceSet(new DBResourceReader(culture, this.dataProvider)); this.cultureResourceSetDictionary[culture.Name] = rs; } } return rs; }
static ResourceManager LoadLanguage(CultureInfo culture, ref ResourceSet rs) { Current = culture; if (rs != null) { rs.Dispose(); rs = null; } try { ResourceManager rManager = new ResourceManager("XPloit.Res.Res", typeof(Lang).Assembly) { IgnoreCase = true }; rs = rManager.GetResourceSet(culture, true, true); return rManager; } catch { } return null; }
private static void AddLocalizedResource(ResourceManager resourceMgr, string cultureName) { using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("ExBuddy.Localization.Localization." + cultureName + ".resources")) { if (s == null) { Logging.WriteDiagnostic("Couldn't find {0}", "ExBuddy.Localization.Localization." + cultureName + ".resources"); return; } FieldInfo resourceSetsField = typeof(ResourceManager).GetField("_resourceSets", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField); Dictionary<string, ResourceSet> resourceSets = (Dictionary<string, ResourceSet>)resourceSetsField.GetValue(resourceMgr); ResourceSet resources = new ResourceSet(s); resourceSets.Add(cultureName, resources); } }
protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents) { ResourceSet rs = (ResourceSet)ResourceSets[culture]; if (rs == null) { string resourceFileName = null; //lazy-load default language (without caring about duplicate assignment in race conditions, no harm done); if (_neutralResourcesCulture == null) { _neutralResourcesCulture = GetNeutralResourcesLanguage(MainAssembly); } // if we're asking for the default language, then ask for the // invariant (non-specific) resources. if (_neutralResourcesCulture.Equals(culture)) culture = CultureInfo.InvariantCulture; resourceFileName = GetResourceFileName(culture); // Only bother to try the lookup based on the resource property if we haven't tried this language before if (!_prevCultures.Contains(culture.ToString()) && culture != CultureInfo.InvariantCulture) { _prevCultures.Add(culture.ToString()); // The T4 template resource generator will link the culture specific resources in to the invariant culture resource // We'll try and load the culture specific resource here var content = GetString("Resources." + culture); if (content != null) { using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(content))) using (var reader = new ResXResourceReader(stream)) { rs = new ResourceSet(reader); } } } if (rs == null) rs = base.InternalGetResourceSet(culture, createIfNotExists, tryParents); } return rs; }
private static ResourceManager GetResourceManager(ref ResourceManager field, ResourceSet name) { if (null == field) { lock (sync) { if (null == field) { var t = typeof(ActionText); var qualifiedName = t.Namespace + "." + Enum.GetName(typeof(ResourceSet), name); field = new ResourceManager(qualifiedName, t.Assembly); } } } return field; }
void Decompile() { Stream s = resource.GetResourceStream(); s.Position = 0; if (resource.Name.EndsWith(".g.resources", StringComparison.OrdinalIgnoreCase)) { IEnumerable<DictionaryEntry> rs = null; try { rs = new ResourceSet(s).Cast<DictionaryEntry>(); } catch (ArgumentException) { } if (rs != null && rs.All(e => e.Value is Stream)) { foreach (var pair in rs) { Stream entryStream = (Stream)pair.Value; byte[] d = new byte[entryStream.Length]; entryStream.Position = 0; if (pair.Key.ToString().EndsWith(".baml", StringComparison.OrdinalIgnoreCase)) { MemoryStream ms = new MemoryStream(); entryStream.CopyTo(ms); // TODO implement extension point // var decompiler = Baml.BamlResourceEntryNode.CreateBamlDecompilerInAppDomain(ref bamlDecompilerAppDomain, assembly.FileName); // string xaml = null; // try { // xaml = decompiler.DecompileBaml(ms, assembly.FileName, new ConnectMethodDecompiler(assembly), new AssemblyResolver(assembly)); // } // catch (XamlXmlWriterException) { } // ignore XAML writer exceptions // if (xaml != null) { // File.WriteAllText(Path.Combine(options.SaveAsProjectDirectory, Path.ChangeExtension(fileName, ".xaml")), xaml); // yield return Tuple.Create("Page", Path.ChangeExtension(fileName, ".xaml")); // continue; // } } else { entryStream.Read(d, 0, (int)entryStream.Length); } string tmp = Path.GetTempFileName(); File.WriteAllBytes(tmp, d); Entries.Add(pair.Key.ToString(), tmp); } } } }
// Private method in framework, had to be re-implemented here. private static void AddResourceSet(Hashtable localResourceSets, CultureInfo culture, ref ResourceSet resourceSet) { lock (localResourceSets) { ResourceSet localResourceSet = (ResourceSet)localResourceSets[culture]; if (localResourceSet != null) { if (!Equals(localResourceSet, resourceSet)) { resourceSet.Dispose(); resourceSet = localResourceSet; } } else { localResourceSets.Add(culture, resourceSet); } } }
//private method in framework, had to be re-specified private static void AddResourceSet(Hashtable localResourceSets, CultureInfo culture, ref ResourceSet rs) { lock (localResourceSets) { ResourceSet objA = (ResourceSet)localResourceSets[culture]; if (objA != null) { if (!object.Equals(objA, rs)) { rs.Dispose(); rs = objA; } } else { localResourceSets.Add(culture, rs); } } }
/// <summary> /// Gets the data from resource file and stores it in a JSON object. /// </summary> /// <param name="fileName">Name of resource file</param> /// <param name="resourceFileLocation">Location of resource file</param> /// <returns> /// JSON object which will have the data from resource file. /// </returns> public static string GetResourceData(string fileName, string resourceFileLocation) { ResourceSet resourceSet; StringBuilder scriptBuilder = new StringBuilder(); try { using (ResXResourceReader resxReader = new ResXResourceReader(HttpContext.Current.Server.MapPath(@"~/" + resourceFileLocation + ConstantStrings.ForwardSlash + fileName + ConstantStrings.ResourceFileExtension))) { resourceSet = new ResourceSet(resxReader); foreach (DictionaryEntry entry in resourceSet) { string resourceKey = (string)entry.Key; object resource = entry.Value; scriptBuilder.Append("\"" + resourceKey + "\":" + "\"" + resource + "\","); } } } catch (Exception exception) { Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, UIConstantStrings.LogTableName); } return string.Concat(Convert.ToString(scriptBuilder, CultureInfo.InvariantCulture).TrimEnd(',')); }
private ResourceSet GetResourceSet(CultureInfo culture, bool custom) { ResourceSet resource; String resourceKey = GetResourceKey(culture, custom); lock(_resourceLock) { // if the resource data for this culture has not yet been loaded, load it if(!ResourceData.TryGetValue(resourceKey, out resource)) { // set the filename according to the cuture String filename; if(null == culture) { filename = "resources.custom.txt"; } else if(culture.Equals(CultureInfo.InvariantCulture)) { filename = "resources.txt"; } else { filename = "resources."; if(custom) { filename += "custom."; } filename += culture.Name.ToLowerInvariant() + ".txt"; } filename = Path.Combine(_resourcePath, filename); // load the resource set and add it into the resource table resource = new ResourceSet(new PlainTextResourceReader(filename)); // Note (arnec): We call GetString to force the lazy loading of the resource stream, thereby making // GetString(), at least theoretically, thread-safe for subsequent calls. resource.GetString("", true); ResourceData.Add(resourceKey, resource); } } return resource; }
/// <summary> /// Register object definitions contained in a /// <see cref="System.Resources.ResourceSet"/>, using all property keys (i.e. /// not filtering by prefix). /// </summary> /// <param name="rs"> /// The <see cref="System.Resources.ResourceSet"/> containing object definitions. /// </param> /// <exception cref="Spring.Objects.ObjectsException"> /// In case of loading or parsing errors. /// </exception> /// <returns>The number of object definitions registered.</returns> public int RegisterObjectDefinitions(ResourceSet rs) { return RegisterObjectDefinitions(rs, string.Empty); }
// Simple helper to ease maintenance and improve readability. private static void AddResourceSet(Dictionary<String,ResourceSet> localResourceSets, String cultureName, ref ResourceSet rs) { // InternalGetResourceSet is both recursive and reentrant - // assembly load callbacks in particular are a way we can call // back into the ResourceManager in unexpectedly on the same thread. lock(localResourceSets) { // If another thread added this culture, return that. ResourceSet lostRace; if (localResourceSets.TryGetValue(cultureName, out lostRace)) { if (!Object.ReferenceEquals(lostRace, rs)) { // Note: In certain cases, we can be trying to add a ResourceSet for multiple // cultures on one thread, while a second thread added another ResourceSet for one // of those cultures. If there is a race condition we must make sure our ResourceSet // isn't in our dictionary before closing it. if (!localResourceSets.ContainsValue(rs)) rs.Dispose(); rs = lostRace; } } else { localResourceSets.Add(cultureName, rs); } } }
public string CreateClassFromResourceSet(ResourceSet resourceSet, string nameSpace, string classname, string fileName) { IsVb = IsFileVb(fileName); StringBuilder sbClass = new StringBuilder(); CreateClassHeader(classname, nameSpace, IsVb, sbClass); string indent = "\t\t"; // Any resource set that contains a '.' is considered a Local Resource bool IsGlobalResource = !classname.Contains("."); // We'll enumerate through the Recordset to get all the resources IDictionaryEnumerator Enumerator = resourceSet.GetEnumerator(); // We have to turn into a concrete Dictionary while (Enumerator.MoveNext()) { DictionaryEntry item = (DictionaryEntry)Enumerator.Current; if (item.Value == null) item.Value = string.Empty; string typeName = item.Value.GetType().FullName; string key = item.Key as string; if (string.IsNullOrEmpty(key)) continue; string varName = SafeVarName(key); // It's a string if (!IsVb) { sbClass.Append(indent + "public static " + typeName + " " + varName + "\r\n" + indent + "{\r\n"); sbClass.AppendFormat(indent + "\tget\r\n" + indent + "\t{{\r\n" + indent + (string.IsNullOrEmpty(typeName) || typeName == "System.String" ? "\t\t" + @"return GeneratedResourceHelper.GetResourceString(""{0}"",""{1}"",ResourceManager,GeneratedResourceSettings.ResourceAccessMode);" + "\r\n" : "\t\t" + @"return ({2}) GeneratedResourceHelper.GetResourceObject(""{0}"",""{1}"",ResourceManager,GeneratedResourceSettings.ResourceAccessMode);" + "\r\n") + indent + "\t}}\r\n", classname, key, typeName); sbClass.Append(indent + "}\r\n\r\n"); } else { sbClass.Append(indent + "Public Shared Property " + varName + "() as " + typeName + "\r\n"); sbClass.AppendFormat(indent + "\tGet\r\n" + indent + "\t\treturn CType( HttpContext.GetGlobalResourceObject(\"{0}\",\"{1}\"), {2})\r\n", classname, key, typeName); sbClass.Append(indent + "\tEnd Get\r\n"); sbClass.Append(indent + "End Property\r\n\r\n"); } } if (!IsVb) sbClass.Append("\t}\r\n\r\n"); else sbClass.Append("End Class\r\n\r\n"); string Output = CreateNameSpaceWrapper(nameSpace, IsVb, sbClass.ToString()); if (!string.IsNullOrEmpty(fileName)) { File.WriteAllText(fileName, Output); return Output; } return sbClass.ToString(); }
[System.Security.SecurityCritical] // auto-generated private static bool IsResourcePresent(String resourceKey) { if (MscorlibResourceSet == null) { MscorlibResourceSet = new ResourceSet(typeof(Environment).Assembly.GetManifestResourceStream("mscorlib.resources")); } return MscorlibResourceSet.GetString(resourceKey) != null; }
/// <summary> /// Register object definitions contained in a /// <see cref="System.Resources.ResourceSet"/>. /// </summary> /// <remarks> /// <p> /// Similar syntax as for an <see cref="System.Collections.IDictionary"/>. /// This method is useful to enable standard .NET internationalization support. /// </p> /// </remarks> /// <param name="rs"> /// The <see cref="System.Resources.ResourceSet"/> containing object definitions. /// </param> /// <param name="prefix"> /// The match or filter for object definition names, e.g. 'objects.' /// </param> /// <exception cref="Spring.Objects.ObjectsException"> /// In case of loading or parsing errors. /// </exception> /// <returns>The number of object definitions registered.</returns> public int RegisterObjectDefinitions(ResourceSet rs, string prefix) { // Simply create a map and call overloaded method IDictionary id = new Hashtable(); foreach (DictionaryEntry de in rs) { id.Add(de.Key, de.Value); } return RegisterObjectDefinitions(id, prefix); }
object GetResource(CallExpression callExpression) { IResourceReader reader = componentCreator.GetResourceReader(CultureInfo.InvariantCulture); if (reader != null) { using (ResourceSet resources = new ResourceSet(reader)) { List<object> args = deserializer.GetArguments(callExpression); return resources.GetObject(args[0] as String); } } return null; }
private static bool WriteResource( ResourceManager resourceManager, ResourceSet neutralSet, StreamWriter writer, bool debug, bool first) { foreach (DictionaryEntry res in neutralSet) { string key = (string)res.Key; string value = resourceManager.GetString(key); if (value != null) { if (first) { first = false; } else { writer.Write(','); } if (debug) writer.WriteLine(); writer.Write('\''); writer.Write(QuoteString(key)); writer.Write("':'"); writer.Write(QuoteString(value)); writer.Write('\''); } } return first; }
IEnumerable<Tuple<string, string>> WriteResourceFilesInProject(LoadedAssembly assembly, DecompilationOptions options, HashSet<string> directories) { //AppDomain bamlDecompilerAppDomain = null; //try { foreach (EmbeddedResource r in assembly.AssemblyDefinition.MainModule.Resources.OfType<EmbeddedResource>()) { string fileName; Stream s = r.GetResourceStream(); s.Position = 0; if (r.Name.EndsWith(".g.resources", StringComparison.OrdinalIgnoreCase)) { IEnumerable<DictionaryEntry> rs = null; try { rs = new ResourceSet(s).Cast<DictionaryEntry>(); } catch (ArgumentException) { } if (rs != null && rs.All(e => e.Value is Stream)) { foreach (var pair in rs) { fileName = Path.Combine(((string)pair.Key).Split('/').Select(p => TextView.DecompilerTextView.CleanUpName(p)).ToArray()); string dirName = Path.GetDirectoryName(fileName); if (!string.IsNullOrEmpty(dirName) && directories.Add(dirName)) { Directory.CreateDirectory(Path.Combine(options.SaveAsProjectDirectory, dirName)); } Stream entryStream = (Stream)pair.Value; entryStream.Position = 0; if (fileName.EndsWith(".baml", StringComparison.OrdinalIgnoreCase)) { MemoryStream ms = new MemoryStream(); entryStream.CopyTo(ms); // TODO implement extension point // var decompiler = Baml.BamlResourceEntryNode.CreateBamlDecompilerInAppDomain(ref bamlDecompilerAppDomain, assembly.FileName); // string xaml = null; // try { // xaml = decompiler.DecompileBaml(ms, assembly.FileName, new ConnectMethodDecompiler(assembly), new AssemblyResolver(assembly)); // } // catch (XamlXmlWriterException) { } // ignore XAML writer exceptions // if (xaml != null) { // File.WriteAllText(Path.Combine(options.SaveAsProjectDirectory, Path.ChangeExtension(fileName, ".xaml")), xaml); // yield return Tuple.Create("Page", Path.ChangeExtension(fileName, ".xaml")); // continue; // } } using (FileStream fs = new FileStream(Path.Combine(options.SaveAsProjectDirectory, fileName), FileMode.Create, FileAccess.Write)) { entryStream.CopyTo(fs); } yield return Tuple.Create("Resource", fileName); } continue; } } fileName = GetFileNameForResource(r.Name, directories); using (FileStream fs = new FileStream(Path.Combine(options.SaveAsProjectDirectory, fileName), FileMode.Create, FileAccess.Write)) { s.CopyTo(fs); } yield return Tuple.Create("EmbeddedResource", fileName); } //} //finally { // if (bamlDecompilerAppDomain != null) // AppDomain.Unload(bamlDecompilerAppDomain); //} }
/// <summary> /// Recursive routine that creates a resource hashtable /// populated with resources for culture and all parent /// cultures. /// </summary> 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 // // TODO: NETSTANDARD2.0 if (System.Stub.ResourceManager_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. // //NETSTANDARD2.0 - GetResourceSet(culture, true, true); resourceSet = System.Stub.ResourceManager_GetResourceSet(culture, true, true); if (resourceSet != null && !object.ReferenceEquals(resourceSet, parentResourceSet)) { foreach (DictionaryEntry de in resourceSet) { sd[(string)de.Key] = de.Value; } } return sd; }