/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_cache != null) { UndoResult ures = 0; while (m_cache.CanUndo) { m_cache.Undo(out ures); if (ures == UndoResult.kuresFailed || ures == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures.ToString()); } } m_cache.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_cache = null; m_styleSheet = null; base.Dispose(disposing); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_sqlCon != null) { m_sqlCon.Close(); } if (m_fdoCache != null) { // Use a transaction because fiddling with Field$ lies outside the Undo/Redo // mechanism. if (m_fdoCache.DatabaseAccessor.IsTransactionOpen()) { m_fdoCache.DatabaseAccessor.RollbackTrans(); } m_fdoCache.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_sqlCon = null; m_fdoCache = null; base.Dispose(disposing); }
public void MultiMessageSynchronize_DifferentCache() { m_mainWnd.Expect("PreSynchronize", new IsAnything()); m_mainWnd.ExpectAndReturn("Synchronize", true, new IsAnything()); m_app.MainWindows.Add((IFwMainWnd)m_mainWnd.MockInstance); FdoCache differentCache = FdoCache.CreateCache(FDOBackendProviderType.kMemoryOnly, BackendBulkLoadDomain.All, null); try { DynamicMock otherMainWnd = new DynamicMock(typeof(IFwMainWnd)); otherMainWnd.SetupResult("Cache", differentCache); otherMainWnd.Expect("PreSynchronize", new IsAnything()); otherMainWnd.ExpectAndReturn("Synchronize", true, new IsAnything()); m_app.MainWindows.Add((IFwMainWnd)otherMainWnd.MockInstance); m_app.SuppressSynchronize(Cache); m_app.Synchronize(SyncMsg.ksyncUndoRedo, Cache); m_app.Synchronize(SyncMsg.ksyncUndoRedo, differentCache); // This should call (Pre)Synchronize once for each main window m_app.ResumeSynchronize(Cache); m_mainWnd.Verify(); otherMainWnd.Verify(); } finally { differentCache.Dispose(); } }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. UndoResult ures = 0; if (m_fdoCache != null) { while (m_fdoCache.CanUndo) { m_fdoCache.Undo(out ures); } m_fdoCache.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_fdoCache = null; m_styleSheet = null; m_scr = null; if (m_wsf != null) { Marshal.ReleaseComObject(m_wsf); m_wsf = null; } base.Dispose(disposing); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged /// resources; <c>false</c> to release only unmanaged resources. /// </param> /// ----------------------------------------------------------------------------------- protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { foreach (ParserConnection connection in m_parsers) { connection.Dispose(); } m_parsers.Clear(); if (components != null) { components.Dispose(); } m_selectedFdoCache.Dispose(); } m_selectedFdoCache = null; m_parsers = null; base.Dispose(disposing); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// ----------------------------------------------------------------------------------- protected override void Dispose(bool fDisposing) { System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); base.Dispose(fDisposing); if (fDisposing) { if (components != null) { components.Dispose(); } if (m_draftView != null) { m_draftView.Dispose(); } if (m_isNewCache && (m_cache != null)) { m_cache.Dispose(); // Only if we made it. } if (m_Persistence != null) { m_Persistence.Dispose(); } } m_cache = null; m_draftView = null; m_styleSheet = null; m_rootb = null; m_Persistence = null; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged /// resources; <c>false</c> to release only unmanaged resources. /// </param> /// ----------------------------------------------------------------------------------- protected override void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { if (m_dataEntryForm != null) { Controls.Remove(m_dataEntryForm); m_dataEntryForm.Dispose(); } if (m_cache != null) { m_cache.Dispose(); } if (components != null) { components.Dispose(); } } m_dataEntryForm = null; m_cache = null; base.Dispose(disposing); }
public void TearDown() { m_lexicon.Dispose(); m_cache.Dispose(); m_activationContext.Dispose(); m_threadHelper.Dispose(); }
public void CreateNewLangProject() { DummyFwNewLangProject dlg = new DummyFwNewLangProject(); string dbName = "Maileingwij2025"; FdoCache cache = null; if (DbExists(dbName)) { DestroyDb(dbName, true); } dlg.ProjectName = dbName; try { dlg.CreateNewLangProj(); Assert.IsTrue(DbExists(dbName)); // // REVIEW: An FDO cache can not be created at this time until the scripture // // object is created. This happens when the database is loaded. // // Check to see if the writing systems were added correctly. // cache = FdoCache.Create(dbName); // Assert.AreEqual(dbName, cache.LangProject.Name.AnalysisDefaultWritingSystem); // Assert.AreEqual(1, cache.LangProject.AnalysisWssRC.Count); // Assert.AreEqual(1, cache.LangProject.VernWssRC.Count); // Assert.AreEqual(1, cache.LangProject.CurAnalysisWssRS.Count); // Assert.AreEqual(1, cache.LangProject.CurVernWssRS.Count); // // foreach (LgWritingSystem ws in cache.LangProject.AnalysisWssRC) // { // Assert.AreEqual("something", ws.Name.GetAlternative(cache.DefaultUserWs)); // } // foreach (LgWritingSystem ws in cache.LangProject.VernWssRC) // { // Assert.AreEqual(dbName, ws.Name.GetAlternative(cache.DefaultUserWs)); // } // foreach (LgWritingSystem ws in cache.LangProject.CurAnalysisWssRS) // { // Assert.AreEqual("something", ws.Name.GetAlternative(cache.DefaultUserWs)); // } // foreach (LgWritingSystem ws in cache.LangProject.CurVernWssRS) // { // Assert.AreEqual(dbName, ws.Name.GetAlternative(cache.DefaultUserWs)); // } cache = FdoCache.Create(dbName); CheckInitialSetOfPartsOfSpeech(cache); } finally { // Blow away the database to clean things up if (cache != null) { cache.Dispose(); } DestroyDb(dbName, false); } }
public void FixtureCleanUp() { if (m_fdoCache != null) { m_fdoCache.Dispose(); m_fdoCache = null; } }
public void TestCleanUp() { if (m_fdoCache != null) { m_fdoCache.Dispose(); m_fdoCache = null; } }
public void Teardown() { if (m_cache != null) { m_cache.Dispose(); m_cache = null; } }
private void DisposeFdoCacheIfUnused(FdoCache fdoCache) { if (m_lexiconCache.All(lexicon => lexicon.Cache != fdoCache)) { m_fdoCacheCache.Remove(fdoCache.ProjectId.Name); fdoCache.ServiceLocator.GetInstance <IUndoStackManager>().Save(); fdoCache.Dispose(); } }
public virtual void Exit() { if (m_fdoCache != null) { m_fdoCache.LanguageWritingSystemFactoryAccessor.Shutdown(); m_fdoCache.Dispose(); m_fdoCache = null; } }
/// <summary> /// /// </summary> protected void DisposeEverythingButBase() { if (m_cache != null) { m_cache.Dispose(); } m_cache = null; m_actionHandler = null; }
public void CleanUpFixture() { m_fdoCache.Dispose(); if (m_regData != null) { m_regData.RestoreRegistryData(); } Unpacker.RemoveParatextTestProjects(); }
public void Deinitialize() { CheckDisposed(); m_exporter = null; m_cache.Dispose(); m_cache = null; m_filter = null; File.Delete(m_fileName); m_fileName = null; }
public virtual void CleanUp() { CheckDisposed(); UndoResult ures = 0; while (m_fdoCache.CanUndo) { m_fdoCache.Undo(out ures); if (ures == UndoResult.kuresFailed || ures == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures.ToString()); } } // Some tests are not at all happy to have m_basicView be disposed befroe the undoing. m_basicView.Dispose(); m_basicView = null; m_fdoCache.Dispose(); m_fdoCache = null; }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. // Dispose window first, as it needs the cache to clear out its notification. if (m_mainWnd != null) { m_mainWnd.Dispose(); } if (m_cache != null) { UndoResult ures = 0; while (m_cache.CanUndo) { m_cache.Undo(out ures); if (ures == UndoResult.kuresFailed || ures == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures.ToString()); } } m_cache.Dispose(); // Yes, since the window isn't supposed to do it. } } // Dispose unmanaged resources here, whether disposing is true or false. m_cache = null; m_mainWnd = null; m_scr = null; // Restore prompt setting Options.ShowEmptyParagraphPromptsSetting = m_saveShowPrompts; // Options is some kind of Registry gizmo. base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; /// <c>false</c> to release only unmanaged resources.</param> /// ------------------------------------------------------------------------------------ protected override void Dispose(bool disposing) { if (disposing) { if (m_fdoCache != null) { m_fdoCache.Dispose(); } } m_fdoCache = null; base.Dispose(disposing); }
static void Main(string[] args) { string db = args[0]; FdoCache c = FdoCache.Create(db); Console.WriteLine("Loaded Cache: " + c.ToString()); FixUp f = new FixUp(c); f.AddMissingMSAs(); f.RemoveExtraAnalyses(); c.Dispose(); }
public void CleanUp() { // For runtime sake, do FdoCache.RestoreTestLangProj in TestFixtureTearDown unless // our individual tests really need a clean database. // FdoCache.RestoreTestLangProj(); m_dialog.Dispose(); m_dialog = null; m_mapping = null; m_styleSheet = null; m_Scripture = null; m_cache.Dispose(); m_cache = null; }
public virtual void Exit() { if (m_fdoCache != null) { m_fdoCache.Dispose(); m_fdoCache = null; } // Make sure we close all the rootboxes if (m_pub != null) { m_pub.Dispose(); } }
public void Destroy() { UndoResult ures = 0; while (m_cache.CanUndo) { m_cache.Undo(out ures); if (ures == UndoResult.kuresFailed || ures == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures.ToString()); } } m_cache.Dispose(); m_cache = null; }
public void CreateNewLangProject() { const string dbName = "Maileingwij2025"; string storePath = FdoFileHelper.GetWritingSystemDir(Path.Combine(FwDirectoryFinder.ProjectsDirectory, dbName)); string sharedStorePath = DirectoryFinder.GlobalWritingSystemStoreDirectory; using (var dlg = new DummyFwNewLangProject()) { FdoCache cache = null; if (DbExists(dbName)) { DestroyDb(dbName, true); } dlg.setProjectName(dbName); try { dlg.CreateNewLangProj(); Assert.IsTrue(DbExists(dbName)); // despite of the name is DummyProgressDlg no real dialog (doesn't derive from Control), so // we don't need a 'using' cache = FdoCache.CreateCacheFromExistingData( new TestProjectId(FDOBackendProviderType.kXML, DbFilename(dbName)), "en", new DummyFdoUI(), FwDirectoryFinder.FdoDirectories, new FdoSettings(), new DummyProgressDlg()); CheckInitialSetOfPartsOfSpeech(cache); Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Count); Assert.AreEqual("English", cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.First().LanguageName); Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Count); Assert.AreEqual("English", cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.LanguageName); Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Count); Assert.AreEqual("French", cache.ServiceLocator.WritingSystems.VernacularWritingSystems.First().LanguageName); Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Count); Assert.AreEqual("French", cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.LanguageName); } finally { // Blow away the database to clean things up if (cache != null) { cache.Dispose(); } DestroyDb(dbName, false); } } }
public void CleanUp() { CheckDisposed(); m_builder = null; m_cache.ActionHandlerAccessor.EndOuterUndoTask(); m_settings = null; while (m_cache.Undo()) { ; } if (m_cache.DatabaseAccessor.IsTransactionOpen()) { m_cache.DatabaseAccessor.RollbackTrans(); } m_cache.Dispose(); m_cache = null; }
public void FDOCompetingTransactions() { CheckDisposed(); FdoCache a = FdoCache.Create("TestlangProj"); AddWord(a); UndoResult ures_a = 0; while (a.CanUndo) { a.Undo(out ures_a); if (ures_a == UndoResult.kuresFailed || ures_a == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures_a.ToString()); } } a.Dispose(); FdoCache b = FdoCache.Create("TestlangProj"); AddWord(b); UndoResult ures_b = 0; while (b.CanUndo) { b.Undo(out ures_b); if (ures_b == UndoResult.kuresFailed || ures_b == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures_b.ToString()); } } b.Dispose(); }
public void TearDown() { m_sda = null; m_cache.Dispose(); m_cache = null; }
public void CleanUp() { m_cache.Dispose(); m_cache = null; }
static void Main(string[] arguments) { /// <summary> /// any filters that we want, for example, to only output items which satisfy their constraint. /// </summary> IFilterStrategy[] filters = null; if (arguments.Length < 3) { Console.WriteLine("usage: fxt dbName fxtTemplatePath xmlOutputPath (-guids)"); Console.WriteLine(""); Console.WriteLine("example using current directory: fxt TestLangProj WebPageSample.xhtml LangProj.xhtml"); Console.WriteLine("example with environment variables: fxt ZPU \"%fwroot%/distfiles/fxtTest.fxt\" \"%temp%/fxtTest.xml\""); return; } string fxtPath = System.Environment.ExpandEnvironmentVariables(arguments[1]); if (!File.Exists(fxtPath)) { Console.WriteLine("could not find the file " + fxtPath); return; } string outputPath = System.Environment.ExpandEnvironmentVariables(arguments[2]); FdoCache cache = null; try { Console.WriteLine("Initializing cache..."); Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("db", arguments[0]); cache = FdoCache.Create(cacheOptions); } catch (Exception error) { Console.WriteLine(error.Message); return; } Console.WriteLine("Beginning output..."); DateTime dtstart = DateTime.Now; XDumper d = new XDumper(cache); if (arguments.Length == 4) { if (arguments[3] == "-parserDump") { filters = new IFilterStrategy[] { new ConstraintFilterStrategy() }; } else { //boy do we have a brain-dead argument parser in this app! System.Diagnostics.Debug.Assert(arguments[3] == "-guids"); } d.OutputGuids = true; } try { d.Go(cache.LangProject as CmObject, fxtPath, File.CreateText(outputPath), filters); //clean up, add the <?xml tag, etc. Won't be necessary if/when we make the dumper use an xmlwriter instead of a textwriter //was introducing changes such as single quote to double quote XmlDocument doc=new XmlDocument(); // doc.Load(outputPath); // doc.Save(outputPath); } catch (Exception error) { if (cache != null) { cache.Dispose(); } Console.WriteLine(error.Message); return; } TimeSpan tsTimeSpan = new TimeSpan(DateTime.Now.Ticks - dtstart.Ticks); Console.WriteLine("Finished: " + tsTimeSpan.TotalSeconds.ToString() + " Seconds"); if (outputPath.ToLower().IndexOf("fxttestout") > -1) { System.Diagnostics.Debug.WriteLine(File.OpenText(outputPath).ReadToEnd()); } if (cache != null) { cache.Dispose(); } System.Diagnostics.Debug.WriteLine("Finished: " + tsTimeSpan.TotalSeconds.ToString() + " Seconds"); }