override public void Remove(string identifier) { //we really need to get it in the trash, else, if was auto-provided, //it'll keep coming back! if (!File.Exists(GetFilePathFromIdentifier(identifier)) && Contains(identifier)) { var ws = Get(identifier); SaveDefinition(ws); } if (File.Exists(GetFilePathFromIdentifier(identifier))) { Directory.CreateDirectory(PathToWritingSystemTrash()); string destination = Path.Combine(PathToWritingSystemTrash(), GetFileNameFromIdentifier(identifier)); //clear out any old on already in the trash if (File.Exists(destination)) { File.Delete(destination); } File.Move(GetFilePathFromIdentifier(identifier), destination); } base.Remove(identifier); if (!Conflating) { _changeLog.LogDelete(identifier); } }
public void Write_NewEmptyFile_WritesModelToLogFile() { using (var e = new TestEnvironment()) { string tempFilePath = Path.Combine(e._tempFolder.Path, "testchangelog.xml"); var log = new WritingSystemChangeLog(new WritingSystemChangeLogDataMapper(tempFilePath)); log.LogChange("aab", "bba"); log.LogAdd("aab"); log.LogDelete("aab"); log.LogConflate("aab","bba"); AssertThatXmlIn.File(tempFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Change/From[text()='aab']"); AssertThatXmlIn.File(tempFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Change/To[text()='bba']"); AssertThatXmlIn.File(tempFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Add/Id[text()='aab']"); AssertThatXmlIn.File(tempFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Delete/Id[text()='aab']"); AssertThatXmlIn.File(tempFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Merge/From[text()='aab']"); AssertThatXmlIn.File(tempFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Merge/To[text()='bba']"); } }
override public void Remove(string storeId) { if (storeId == null) { throw new ArgumentNullException("storeId"); } if (!Contains(storeId)) { throw new ArgumentOutOfRangeException("storeId"); } // Remove() uses the StoreID field, but file storage uses the Id field. var ws = Get(storeId); string identifier = ws.Id; // may differ from storeId!! //we really need to get it in the trash, else, if was auto-provided, //it'll keep coming back! if (!File.Exists(GetFilePathFromIdentifier(identifier))) { SaveDefinition(ws); storeId = ws.StoreID; // Save() may change StoreID. } if (File.Exists(GetFilePathFromIdentifier(identifier))) { Directory.CreateDirectory(PathToWritingSystemTrash()); string destination = Path.Combine(PathToWritingSystemTrash(), GetFileNameFromIdentifier(identifier)); //clear out any old on already in the trash if (File.Exists(destination)) { File.Delete(destination); } File.Move(GetFilePathFromIdentifier(identifier), destination); } base.Remove(storeId); if (!Conflating) { _changeLog.LogDelete(identifier); } }