/// <summary> /// Copies all values from source to target resource set /// </summary> private static void CopyResourceSetContent(ResourceSet source, ResourceSet target, BaseValuesFilter filter) { foreach (var sourceResourceItem in source.Values.Where(p => !p.Locked)) { if (!target.ContainsKey(sourceResourceItem.Name)) { var targetResourceItem = new ResourceItem(); targetResourceItem.Name = sourceResourceItem.Name; targetResourceItem.Value = sourceResourceItem.Value; target.Add(sourceResourceItem.Name, targetResourceItem); } else { if (target[sourceResourceItem.Name].ValueEmpty || filter == BaseValuesFilter.AllUnlocked) { target[sourceResourceItem.Name].Value = sourceResourceItem.Value; } } } }
/// <summary> /// Copies all values from source to target resource set /// </summary> private static void CopyResourceSetContent(ResourceSet source, ResourceSet target, BaseValuesFilter filter) { foreach (var sourceResourceItem in source.Values.Where(p => !p.Locked)) { if (!target.ContainsKey(sourceResourceItem.Name)) { var targetResourceItem = new ResourceItem(); targetResourceItem.Name = sourceResourceItem.Name; targetResourceItem.Value = sourceResourceItem.Value; target.Add(sourceResourceItem.Name, targetResourceItem); } else { if (target[sourceResourceItem.Name].ValueEmpty || filter == BaseValuesFilter.AllUnlocked) { target[sourceResourceItem.Name].Value = sourceResourceItem.Value; } } } }
public void ResXFile2ResourceSetTest() { var actual = new ResourceSet(ResourceSet.NeutralCulture); ResXResourceBundleAdapter_Accessor.Resx2ResourceSet(actual, "ResXResourceBundleAdapterTest.Sample.resx", null); Assert.AreEqual(15, actual.Values.Count); Assert.IsTrue(actual.ContainsKey("Ampersands")); Assert.IsTrue(actual.ContainsKey("MaxLengthString")); Assert.IsTrue(actual.ContainsKey("ReadOnlyString")); Assert.IsTrue(actual.ContainsKey("Set1_Placeholder1")); Assert.IsTrue(actual.ContainsKey("Set1_Placeholder2")); Assert.IsTrue(actual.ContainsKey("Set2")); Assert.IsTrue(actual.ContainsKey("Set2_SubString1")); Assert.IsTrue(actual.ContainsKey("Set2_SubString2")); Assert.IsTrue(actual.ContainsKey("String2Multiline")); Assert.IsTrue(actual.ContainsKey(">>FrameworkLocked")); Assert.IsTrue(actual.ContainsKey("Exclude1")); Assert.IsTrue(actual.ContainsKey("StringWithExclusions")); Assert.IsTrue(actual.ContainsKey("ItemWithoutValue")); Assert.AreEqual(4, actual.CountLocked()); Assert.AreEqual(13, actual.CountStringItems(false)); Assert.AreEqual(14, actual.CountStringItems(true)); Assert.AreEqual(52, actual.CountWords()); Assert.IsInstanceOfType(actual["MaxLengthString"], typeof(ResourceStringItem)); var item = (ResourceStringItem)actual["MaxLengthString"]; Assert.AreEqual(10, item.MaxLength); Assert.IsTrue(actual["ReadOnlyString"].Locked); Assert.AreEqual(LockedReason.DeveloperLock, actual["ReadOnlyString"].LockedReason); Assert.IsTrue(actual[">>FrameworkLocked"].Locked); Assert.AreEqual(LockedReason.FrameworkLock, actual[">>FrameworkLocked"].LockedReason); Assert.IsTrue(actual["Exclude1"].Locked); Assert.AreEqual(LockedReason.ResexMetadata, actual["Exclude1"].LockedReason); // exclusions var exclusions = actual.Exclusions; Assert.AreEqual(3, exclusions.Count); Assert.AreEqual(@"\{.*}", exclusions[1].Pattern); Assert.AreEqual(@"{Text}", exclusions[1].Sample); Assert.AreEqual(@"Windows", exclusions[2].Pattern); }
public void ResXFile2ResourceSetTest() { var actual = new ResourceSet(ResourceSet.NeutralCulture); ResXResourceBundleAdapter_Accessor.Resx2ResourceSet(actual, "ResXResourceBundleAdapterTest.Sample.resx", null); Assert.AreEqual(15, actual.Values.Count); Assert.IsTrue(actual.ContainsKey("Ampersands")); Assert.IsTrue(actual.ContainsKey("MaxLengthString")); Assert.IsTrue(actual.ContainsKey("ReadOnlyString")); Assert.IsTrue(actual.ContainsKey("Set1_Placeholder1")); Assert.IsTrue(actual.ContainsKey("Set1_Placeholder2")); Assert.IsTrue(actual.ContainsKey("Set2")); Assert.IsTrue(actual.ContainsKey("Set2_SubString1")); Assert.IsTrue(actual.ContainsKey("Set2_SubString2")); Assert.IsTrue(actual.ContainsKey("String2Multiline")); Assert.IsTrue(actual.ContainsKey(">>FrameworkLocked")); Assert.IsTrue(actual.ContainsKey("Exclude1")); Assert.IsTrue(actual.ContainsKey("StringWithExclusions")); Assert.IsTrue(actual.ContainsKey("ItemWithoutValue")); Assert.AreEqual(4, actual.CountLocked()); Assert.AreEqual(13, actual.CountStringItems(false)); Assert.AreEqual(14, actual.CountStringItems(true)); Assert.AreEqual(52, actual.CountWords()); Assert.IsInstanceOfType(actual["MaxLengthString"], typeof(ResourceStringItem)); var item = (ResourceStringItem)actual["MaxLengthString"]; Assert.AreEqual(10, item.MaxLength); Assert.IsTrue(actual["ReadOnlyString"].Locked); Assert.AreEqual(LockedReason.DeveloperLock, actual["ReadOnlyString"].LockedReason); Assert.IsTrue(actual[">>FrameworkLocked"].Locked); Assert.AreEqual(LockedReason.FrameworkLock, actual[">>FrameworkLocked"].LockedReason); Assert.IsTrue(actual["Exclude1"].Locked); Assert.AreEqual(LockedReason.ResexMetadata, actual["Exclude1"].LockedReason); // exclusions var exclusions = actual.Exclusions; Assert.AreEqual(3, exclusions.Count); Assert.AreEqual(@"\{.*}", exclusions[1].Pattern); Assert.AreEqual(@"{Text}", exclusions[1].Sample); Assert.AreEqual(@"Windows", exclusions[2].Pattern); }
/// <summary> /// Updates the given grid row using the corresponding resource item of the given resource set /// </summary> private void UpdateGridRowFromResourceItem(DataGridViewRow row, ResourceSet resourceSet) { string rowKey = row.Cells[ColumnNames.Key].Value.ToString(); // if given resource set does not contain resource item for the row // then put all values to null if (!resourceSet.ContainsKey(rowKey)) { row.Cells[ColumnNames.LocalValue].Value = null; row.Cells[ColumnNames.LocalComment].Value = null; RowSetStatus(row, null); } else { ResourceItem resourceItem = resourceSet[rowKey]; row.Cells[ColumnNames.LocalValue].Value = resourceItem.Value; row.Cells[ColumnNames.LocalComment].Value = resourceItem.Comment; RowSetStatus(row, resourceItem); } row.Height = row.GetPreferredHeight(row.Index, DataGridViewAutoSizeRowMode.AllCells, true); }