Skip to content

Commit

Permalink
Merge pull request #1 from Hoshiheibel/master
Browse files Browse the repository at this point in the history
Added comparision with existing FullLookAndFeel xaml file
  • Loading branch information
dctdct committed Jul 8, 2016
2 parents 1026ead + 25dba9b commit f1ac44c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ResMerger/ResourceMerger.cs
Expand Up @@ -138,13 +138,32 @@ public static void MergeResources(string projectPath, string projectName = null,
outputDoc.Root.SetAttributeValue(attribute.Name, attribute.Value);

// add elements
outputDoc.Root.Add(item.Value.Document.Root.Elements().Where(e => !e.Name.LocalName.StartsWith(resDictString)));
outputDoc.Root.Add(item.Value.Document.Root.Elements().Where(e => !e.Name.LocalName.StartsWith(resDictString)));
}

using (var ms = new MemoryStream())
{
outputDoc.Save(ms);

if (OutputEqualsExistingFileContent(Path.Combine(projectPath, relativeOutputFilePath), ms.ToArray()))
return;
}

// save file
outputDoc.Save(projectPath + relativeOutputFilePath);
}

private static bool OutputEqualsExistingFileContent(string targetFileName, IEnumerable<byte> newFileContent)
{
var normalizedFileName = targetFileName.Replace("/", "\\");

// don't check for equality if the FullLookAndFeel.xaml doesn't exist already
if (!File.Exists(normalizedFileName))
return false;

var existingFileContentBytes = File.ReadAllBytes(normalizedFileName);
return newFileContent.SequenceEqual(existingFileContentBytes); ;
}

/// <summary>
/// Get a collection of resource dictionary source paths respecting the dependencies
Expand Down

0 comments on commit f1ac44c

Please sign in to comment.