/// <summary> /// Sets the available keyboard adaptors /// </summary> public static void SetKeyboardAdaptors(IKeyboardAdaptor[] adaptors) { if (SingletonsContainer.Contains <IKeyboardController>()) { // we're modifying an existent KeyboardController. Instance.Keyboards.Clear(); if (Adaptors != null) { foreach (var adaptor in Adaptors) { adaptor.Close(); } } Adaptors = adaptors; InitializeAdaptors(); } else { // KeyboardController doesn't exist yet. We'll initialize the adaptors // when the KeyboardController gets created Adaptors = adaptors; } }
///<summary> ///</summary> public static void Release() { if (!SingletonsContainer.Contains <LogFileImpl>()) { return; } AddLine("----- LogFile Object Released -----"); SingletonsContainer.Get <LogFileImpl>().Shutdown(); SingletonsContainer.Remove(SingletonsContainer.Get <LogFileImpl>()); }
public FwProject(LfMergeSettings settings, string database) { // We don't want to use a global writing system store, so we insert a null singleton if (!SingletonsContainer.Contains <CoreGlobalWritingSystemRepository>()) { SingletonsContainer.Add(typeof(CoreGlobalWritingSystemRepository).FullName, null); } _project = new ProjectIdentifier(settings.LcmDirectorySettings, database); _lcmUi = new ConsoleLcmUi(_progress.SynchronizeInvoke); Cache = TryGetLcmCache(); if (Cache != null) { ServiceLocator = new FwServiceLocatorCache(Cache.ServiceLocator); } }
public TestEnvironment(bool registerSettingsModelDouble = true, bool registerProcessingStateDouble = true, bool resetLfProjectsDuringCleanup = true, TemporaryFolder languageForgeServerFolder = null) { _resetLfProjectsDuringCleanup = resetLfProjectsDuringCleanup; _languageForgeServerFolder = languageForgeServerFolder ?? new TemporaryFolder(TestName + Path.GetRandomFileName()); Environment.SetEnvironmentVariable("FW_CommonAppData", _languageForgeServerFolder.Path); MainClass.Container = RegisterTypes(registerSettingsModelDouble, registerProcessingStateDouble, _languageForgeServerFolder.Path).Build(); Settings = MainClass.Container.Resolve <LfMergeSettings>(); MainClass.Logger = MainClass.Container.Resolve <ILogger>(); Directory.CreateDirectory(Settings.LcmDirectorySettings.ProjectsDirectory); Directory.CreateDirectory(Settings.LcmDirectorySettings.TemplateDirectory); Directory.CreateDirectory(Settings.StateDirectory); _mongoConnection = MainClass.Container.Resolve <IMongoConnection>() as MongoConnectionDouble; // only call SingletonsContainer.Release() at the end if we actually create the // singleton _releaseSingletons = !SingletonsContainer.Contains <CoreGlobalWritingSystemRepository>(); }