using System.Collections.Generic; using PatcherShared; namespace Differ { public class DiffToPatchfileEncoder { #region .ctor #endregion #region Methods public PatchFile Encode(IEnumerable diffs) { PatchFile file = new PatchFile(); foreach (var diff in diffs) { EncodeSingleDiff(diff, file); } return file; } private void EncodeSingleDiff(Difference diff, PatchFile file) { PatchFile.Action act; switch (diff.Difftype) { case DiffType.RedundantFile: act = new PatchFile.Action(file) { Type = PatchFile.Action.ActionType.DeleteFile, ClientPath = diff.TargetPath }; break; case DiffType.MissingFile: act = new PatchFile.Action(file) { Type = PatchFile.Action.ActionType.AlterOrCreateFile, ClientPath = diff.TargetPath }; PatchFile.File f = new PatchFile.File(file) { FileName = diff.SourcePath }; break; default: break; } } #endregion #region Properties #endregion #region Variables #endregion } }