private static void MergeChangesIntoResx(ResxDifferences changes, Dictionary<string, object> currentEntries,
            Stream newResxStream)
        {
            var addedKeys = changes.ResourcesAdded.Select(pair => pair.Key);
            var removedKeys = changes.ResourcesRemoved.Select(pair => pair.Key);

            using (var writer = new ResXResourceWriter(newResxStream))
            {
                foreach (var resourceEntry in currentEntries)
                {
                    string currentKey = resourceEntry.Key;
                    if (addedKeys.Contains(currentKey))
                        continue;
                    if (removedKeys.Contains(currentKey))
                        continue;

                    var modifiedResource = changes.ResourcesModified.FirstOrDefault(mod => mod.ResourceName == currentKey);
                    if (modifiedResource != null)
                        writer.AddResource(currentKey, modifiedResource.NewValue);
                    else
                        writer.AddResource(currentKey, resourceEntry.Value);
                }

                changes.ResourcesAdded.ForEach(res => writer.AddResource(res.Key, res.Value));
            }
        }
        public static void MergeChangesIntoResx(ResxDifferences changes, IFileInfo targetResxFile)
        {
            Dictionary<string, object> currentEntries;
            using (var stream = targetResxFile.Open(FileMode.Open, FileAccess.Read))
            {
                currentEntries = ReadAllResxEntries(stream);
            }

            using (var newStream = targetResxFile.Open(FileMode.Truncate, FileAccess.Write))
            {
                MergeChangesIntoResx(changes, currentEntries, newStream);
            }
        }