private void CreateAndPopulateDataTable(DataSet data, ResourceExportLanguage language, FileInfo file, string tableName) { System.Data.DataTable table = CreateDataTable(language, tableName); PopulateDataTable(language, file, table); data.Tables.Add(table); }
private static System.Data.DataTable CreateDataTable(ResourceExportLanguage language, string tableName) { System.Data.DataTable table = new System.Data.DataTable(); table.TableName = tableName; table.Columns.Add(Key); table.Columns.Add(language.Encoding); return(table); }
private IEnumerable <DictionaryEntry> GetQueryableDataSet(DataSet data, ResourceExportLanguage language) { foreach (System.Data.DataTable t in data.Tables) { foreach (System.Data.DataRow row in t.Rows) { yield return(new DictionaryEntry(row[Key], row[language.Encoding])); } } }
private void PopulateDataTable(ResourceExportLanguage language, FileInfo file, System.Data.DataTable table, bool update = false) { #pragma warning disable CS0219 // Variable is assigned but its value is never used System.ComponentModel.Design.ITypeResolutionService typeres = null; #pragma warning restore CS0219 // Variable is assigned but its value is never used using (ResXResourceReader resx = new ResXResourceReader(file.FullName)) { resx.UseResXDataNodes = true; foreach (DictionaryEntry entry in resx) { ResXDataNode node = (ResXDataNode)entry.Value; if (SkipEntryComments?.Length > 0) { if (SkipEntryComments.Contains(node.Comment)) { if (update) { for (int i = 0; i < table.Rows.Count; ++i) { if (table.Rows[i][Key].ToString() == entry.Key.ToString()) { table.Rows.RemoveAt(i); break; } } } continue; } } if (!update) { var row = table.Rows.Add(entry.Key); row[language.Encoding] = node.GetValue(typeres); } else { for (int i = 0; i < table.Rows.Count; ++i) { if (table.Rows[i][Key].ToString() == entry.Key.ToString()) { table.Rows[i][language.Encoding] = node.GetValue(typeres); } } } } } }