public void Add(NpkDirContents other) { foreach (NpkPath npkPath in other._imgFrames.Keys) { if (!_imgFrames.ContainsKey(npkPath)) { _imgFrames[npkPath] = other._imgFrames[npkPath]; } } }
static NpkDirContents GetNpkDirContents(string npkDir) { NpkDirContents allContents = new NpkDirContents(); foreach (string npkFilePath in Directory.GetFiles(npkDir, "*.NPK", SearchOption.TopDirectoryOnly)) { NpkDirContents npkContents = GetNpkContents(npkFilePath); allContents.Add(npkContents); } return allContents; }
static NpkDirContents GetNpkDirContents(string npkDir) { NpkDirContents allContents = new NpkDirContents(); foreach (string npkFilePath in Directory.GetFiles(npkDir, "*.NPK", SearchOption.TopDirectoryOnly)) { NpkDirContents npkContents = GetNpkContents(npkFilePath); allContents.Add(npkContents); } return(allContents); }
public NpkDirDifferences GetDifferences(NpkDirContents other) { if (other == null) { throw new ArgumentNullException("other"); } List <ImgInfo> imgsInFirstButNotSecond = new List <ImgInfo>(); List <ImgInfo> imgsInSecondButNotFirst = new List <ImgInfo>(); Dictionary <NpkPath, FrameCountDifferenceInfo> imgsWithFewerFramcesInSecond = new Dictionary <NpkPath, FrameCountDifferenceInfo>(); Dictionary <NpkPath, FrameCountDifferenceInfo> imgsWithMoreFramesInSecond = new Dictionary <NpkPath, FrameCountDifferenceInfo>(); foreach (NpkPath npkPath in this._imgFrames.Keys) { if (!other._imgFrames.ContainsKey(npkPath)) { imgsInFirstButNotSecond.Add(this._imgFrames[npkPath]); } else { int thisFrameCount = this._imgFrames[npkPath].FrameCount; string thisNpkFilePath = this._imgFrames[npkPath].NpkFileName; int otherFrameCount = other._imgFrames[npkPath].FrameCount; string otherNpkFilePath = other._imgFrames[npkPath].NpkFileName; if (thisFrameCount > otherFrameCount) { imgsWithFewerFramcesInSecond[npkPath] = new FrameCountDifferenceInfo(thisFrameCount, thisNpkFilePath, otherFrameCount, otherNpkFilePath); } else if (thisFrameCount < otherFrameCount) { imgsWithMoreFramesInSecond[npkPath] = new FrameCountDifferenceInfo(thisFrameCount, thisNpkFilePath, otherFrameCount, otherNpkFilePath); } } } foreach (NpkPath npkPath in other._imgFrames.Keys) { if (!this._imgFrames.ContainsKey(npkPath)) { imgsInSecondButNotFirst.Add(other._imgFrames[npkPath]); } } return(new NpkDirDifferences(imgsInFirstButNotSecond, imgsWithFewerFramcesInSecond, imgsInSecondButNotFirst, imgsWithMoreFramesInSecond)); }
public NpkDirDifferences GetDifferences(NpkDirContents other) { if (other == null) throw new ArgumentNullException("other"); List<ImgInfo> imgsInFirstButNotSecond = new List<ImgInfo>(); List<ImgInfo> imgsInSecondButNotFirst = new List<ImgInfo>(); Dictionary<NpkPath, FrameCountDifferenceInfo> imgsWithFewerFramcesInSecond = new Dictionary<NpkPath, FrameCountDifferenceInfo>(); Dictionary<NpkPath, FrameCountDifferenceInfo> imgsWithMoreFramesInSecond = new Dictionary<NpkPath, FrameCountDifferenceInfo>(); foreach (NpkPath npkPath in this._imgFrames.Keys) { if (!other._imgFrames.ContainsKey(npkPath)) { imgsInFirstButNotSecond.Add(this._imgFrames[npkPath]); } else { int thisFrameCount = this._imgFrames[npkPath].FrameCount; string thisNpkFilePath = this._imgFrames[npkPath].NpkFileName; int otherFrameCount = other._imgFrames[npkPath].FrameCount; string otherNpkFilePath = other._imgFrames[npkPath].NpkFileName; if (thisFrameCount > otherFrameCount) { imgsWithFewerFramcesInSecond[npkPath] = new FrameCountDifferenceInfo(thisFrameCount, thisNpkFilePath, otherFrameCount, otherNpkFilePath); } else if (thisFrameCount < otherFrameCount) { imgsWithMoreFramesInSecond[npkPath] = new FrameCountDifferenceInfo(thisFrameCount, thisNpkFilePath, otherFrameCount, otherNpkFilePath); } } } foreach (NpkPath npkPath in other._imgFrames.Keys) { if (!this._imgFrames.ContainsKey(npkPath)) { imgsInSecondButNotFirst.Add(other._imgFrames[npkPath]); } } return new NpkDirDifferences(imgsInFirstButNotSecond, imgsWithFewerFramcesInSecond, imgsInSecondButNotFirst, imgsWithMoreFramesInSecond); }
static void Main(string[] args) { try { CommandLineArgs cmdline = new CommandLineArgs(args); // read *.NPK in NpkDir1 // read *.NPK in NpkDir2 // Compare NpkDirContents dir1Contents = GetNpkDirContents(cmdline.NpkDir1); NpkDirContents dir2Contents = GetNpkDirContents(cmdline.NpkDir2); NpkDirDifferences differences = dir1Contents.GetDifferences(dir2Contents); DisplayDifferences(differences); } catch (Exception ex) { Console.Error.WriteLine("Unexpected error: {0}", ex.Message); } }