/// <summary/> public override void BeforeTest(TestDetails testDetails) { base.BeforeTest(testDetails); m_activationContext = new ActivationContextHelper("FieldWorks.Tests.manifest"); m_currentActivation = m_activationContext.Activate(); m_debugProcs = new DebugProcs(); if (!Platform.IsWindows) { try { using (var process = System.Diagnostics.Process.GetCurrentProcess()) { // try to change PTRACE option so that unmanaged call stacks show more useful // information. Since Ubuntu 10.10 a normal user is no longer allowed to use // PTRACE. This prevents call stacks and assertions from working properly. // However, we can set a flag on the currently running process to allow // it. See also the similar code in Generic/ModuleEntry.cpp prctl(PR_SET_PTRACER, (IntPtr)process.Id, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); } } catch (Exception e) { // just ignore any errors we get } } }
/// <summary> /// Override to dispose managed resources. /// </summary> protected override void DisposeManagedResources() { if (m_activationContext != null) { using (m_activationContext.Activate()) { lock (m_syncRoot) { foreach (FdoLexicon lexicon in m_lexiconCache) { lexicon.Dispose(); } m_lexiconCache.Clear(); foreach (FdoCache fdoCache in m_fdoCacheCache) { fdoCache.ServiceLocator.GetInstance <IUndoStackManager>().Save(); fdoCache.Dispose(); } m_fdoCacheCache.Clear(); } } m_activationContext.Dispose(); m_activationContext = null; } }
/// <summary/> public override void BeforeTest(TestDetails testDetails) { base.BeforeTest(testDetails); #if !__MonoCS__ m_activationContext = new ActivationContextHelper("FieldWorks.Tests.manifest"); m_currentActivation = m_activationContext.Activate(); #endif }
internal FdoLexicon(string scrTextName, string projectId, FdoCache cache, int defaultVernWs, ActivationContextHelper activationContext) { m_scrTextName = scrTextName; m_projectId = projectId; m_cache = cache; m_homographNumbers = new ConditionalWeakTable <ILexEntry, HomographNumber>(); m_cache.DomainDataByFlid.AddNotification(this); m_entryComparer = new LexEntryComparer(this); m_defaultVernWs = defaultVernWs; m_activationContext = activationContext; }
/// <summary> /// Initializes a new instance of the <see cref="FwLexiconPlugin"/> class. /// </summary> public FwLexiconPlugin() { RegistryHelper.CompanyName = DirectoryFinder.CompanyName; RegistryHelper.ProductName = "FieldWorks"; // setup necessary environment variables on Linux if (MiscUtils.IsUnix) { // update ICU_DATA to location of ICU data files if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ICU_DATA"))) { string codeIcuDataPath = Path.Combine(ParatextLexiconPluginDirectoryFinder.CodeDirectory, "Icu" + Icu.Version); #if DEBUG string icuDataPath = codeIcuDataPath; #else string icuDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), ".config/fieldworks/Icu" + Icu.Version); if (!Directory.Exists(icuDataPath)) { icuDataPath = codeIcuDataPath; } #endif Environment.SetEnvironmentVariable("ICU_DATA", icuDataPath); } // update COMPONENTS_MAP_PATH to point to code directory so that COM objects can be loaded properly if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("COMPONENTS_MAP_PATH"))) { string compMapPath = Path.GetDirectoryName(FileUtils.StripFilePrefix(Assembly.GetExecutingAssembly().CodeBase)); Environment.SetEnvironmentVariable("COMPONENTS_MAP_PATH", compMapPath); } // update FW_ROOTCODE so that strings-en.txt file can be found if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("FW_ROOTCODE"))) { Environment.SetEnvironmentVariable("FW_ROOTCODE", ParatextLexiconPluginDirectoryFinder.CodeDirectory); } } Icu.InitIcuDataDir(); m_syncRoot = new object(); m_lexiconCache = new FdoLexiconCollection(); m_fdoCacheCache = new FdoCacheCollection(); m_activationContext = new ActivationContextHelper("FwParatextLexiconPlugin.dll.manifest"); // initialize client-server services to use Db4O backend for FDO m_ui = new ParatextLexiconPluginFdoUI(m_activationContext); var dirs = ParatextLexiconPluginDirectoryFinder.FdoDirectories; ClientServerServices.SetCurrentToDb4OBackend(m_ui, dirs); }
public void SetUp() { Icu.InitIcuDataDir(); m_activationContext = new ActivationContextHelper("FwParatextLexiconPlugin.dll.manifest"); using (m_activationContext.Activate()) { m_threadHelper = new ThreadHelper(); var ui = new DummyFdoUI(m_threadHelper); var projectId = new ParatextLexiconPluginProjectID(FDOBackendProviderType.kMemoryOnly, "Test.fwdata"); m_cache = FdoCache.CreateCacheWithNewBlankLangProj(projectId, "en", "fr", "en", ui, ParatextLexiconPluginDirectoryFinder.FdoDirectories, new FdoSettings()); NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () => { m_cache.ServiceLocator.WritingSystems.AddToCurrentAnalysisWritingSystems(m_cache.ServiceLocator.WritingSystemManager.Get("fr")); m_cache.ServiceLocator.WritingSystems.AddToCurrentVernacularWritingSystems(m_cache.ServiceLocator.WritingSystemManager.Get("en")); m_cache.LangProject.MorphologicalDataOA.ParserParameters = "<ParserParameters><XAmple><MaxNulls>1</MaxNulls><MaxPrefixes>5</MaxPrefixes><MaxInfixes>1</MaxInfixes><MaxSuffixes>5</MaxSuffixes><MaxInterfixes>0</MaxInterfixes><MaxAnalysesToReturn>10</MaxAnalysesToReturn></XAmple><ActiveParser>XAmple</ActiveParser></ParserParameters>"; }); } m_lexicon = new FdoLexicon("Test", "FieldWorks:Test", m_cache, m_cache.DefaultVernWs, m_activationContext); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Executes the background task. /// </summary> /// <remarks>This method runs in the background thread!</remarks> /// ------------------------------------------------------------------------------------ private void RunBackgroundTask(object sender, DoWorkEventArgs e) { if (string.IsNullOrEmpty(Thread.CurrentThread.Name)) { Thread.CurrentThread.Name = "Background thread"; } m_Exception = null; m_RetValue = null; ActivationContextHelper activationContext = null; IDisposable activation = null; try { if (MiscUtils.RunningTests) { activationContext = new ActivationContextHelper("FieldWorks.Tests.manifest"); activation = activationContext.Activate(); } m_RetValue = m_backgroundTask(this, m_parameters); } catch (Exception ex) { Debug.WriteLine("Got exception in background thread: " + ex.Message); m_Exception = ex; } finally { if (activation != null) { activation.Dispose(); } if (activationContext != null) { activationContext.Dispose(); } } }
public ParatextLexiconPluginFdoUI(ActivationContextHelper activationContext) { m_synchronizeInvoke = new SynchronizeInvokeWrapper(activationContext); m_activityMonitor = new UserActivityMonitor(); m_activityMonitor.StartMonitoring(); }
public SynchronizeInvokeWrapper(ActivationContextHelper activationContext) { m_activationContext = activationContext; m_control = new Control(); m_control.CreateControl(); }
public SynchronizeInvokeWrapper(ActivationContextHelper activationContext) { m_activationContext = activationContext; }