public async Task RecreateWithOpenConnectionAfterStartup() { /* * could be supported by running the following in wrapper CreateDatabaseFromTemplate * but it is fairly unlikely to happen and not doing the offline saves time in tests * * if db_id('{name}') is not null * begin * alter database [{name}] set single_user with rollback immediate; * alter database [{name}] set multi_user; * alter database [{name}] set offline; * end; */ LocalDbApi.StopAndDelete("RecreateWithOpenConnectionAfterStartup"); DirectoryFinder.Delete("RecreateWithOpenConnectionAfterStartup"); var wrapper = new Wrapper("RecreateWithOpenConnectionAfterStartup", DirectoryFinder.Find("RecreateWithOpenConnectionAfterStartup")); wrapper.Start(timestamp, TestDbBuilder.CreateTable); var connectionString = await wrapper.CreateDatabaseFromTemplate("Simple"); using (var connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); await wrapper.CreateDatabaseFromTemplate("Simple"); wrapper = new Wrapper("RecreateWithOpenConnectionAfterStartup", DirectoryFinder.Find("RecreateWithOpenConnection")); wrapper.Start(timestamp, TestDbBuilder.CreateTable); await wrapper.CreateDatabaseFromTemplate("Simple"); } ObjectApprover.Verify(await wrapper.ReadDatabaseState("Simple")); LocalDbApi.StopInstance("RecreateWithOpenConnectionAfterStartup"); }
public void LinkedFilesRootDirTests() { //test when LinkedFiles is in the project's root folder var projectFolder = Path.Combine(FwDirectoryFinder.ProjectsDirectory, "TestProjectName"); var linkedFilesFullPath = Path.Combine(projectFolder, "LinkedFiles"); Cache.LanguageProject.LinkedFilesRootDir = linkedFilesFullPath; var outputLinkedFilesFullPath = Cache.LanguageProject.LinkedFilesRootDir; Assert.True(linkedFilesFullPath.Equals(outputLinkedFilesFullPath)); //test when linked files is in FW Projects folder linkedFilesFullPath = Path.Combine(FwDirectoryFinder.ProjectsDirectory, "LinkedFiles"); Cache.LanguageProject.LinkedFilesRootDir = linkedFilesFullPath; outputLinkedFilesFullPath = Cache.LanguageProject.LinkedFilesRootDir; Assert.True(linkedFilesFullPath.Equals(outputLinkedFilesFullPath)); //test when linked files is in the CommonApplicationData shared folder linkedFilesFullPath = Path.Combine(DirectoryFinder.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "LinkedFiles"); Cache.LanguageProject.LinkedFilesRootDir = linkedFilesFullPath; outputLinkedFilesFullPath = Cache.LanguageProject.LinkedFilesRootDir; Assert.True(linkedFilesFullPath.Equals(outputLinkedFilesFullPath)); //test when the linked files is in the User's MyDocuments folder linkedFilesFullPath = Path.Combine(DirectoryFinder.GetFolderPath(Environment.SpecialFolder.MyDocuments), "LinkedFiles"); Cache.LanguageProject.LinkedFilesRootDir = linkedFilesFullPath; outputLinkedFilesFullPath = Cache.LanguageProject.LinkedFilesRootDir; Assert.True(linkedFilesFullPath.Equals(outputLinkedFilesFullPath)); //test when the linked files is in some other location and therefore is just stored as an absolute full path. linkedFilesFullPath = Path.Combine(DirectoryFinder.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "LinkedFiles"); Cache.LanguageProject.LinkedFilesRootDir = linkedFilesFullPath; outputLinkedFilesFullPath = Cache.LanguageProject.LinkedFilesRootDir; Assert.True(linkedFilesFullPath.Equals(outputLinkedFilesFullPath)); }
private static string GetPath() { var dbName = CoreParametersConfig.GetAntdDb(); var directories = new DirectoryFinder("/", dbName).List; return(string.Join(", ", directories).ToString()); }
public void GetFiles_WordThenParentThenWordWithWildcardThenWord() { var filename = "readme.txt"; var pattern = "tests/../addin?/" + filename; var finder = new DirectoryFinder(this.fileSystem); var baseDir = this.GetFakeDirectory("tools", "metamorphosator"); var targetDir = this.GetFakeDirectory("tools", "metamorphosator", "addins"); baseDir.GetDirectories("tests", SIO.SearchOption.TopDirectoryOnly).Returns(new[] { this.GetFakeDirectory("tools", "metamorphosator", "tests") }); this.GetFakeDirectory("tools", "metamorphosator").GetDirectories("addin?", SIO.SearchOption.TopDirectoryOnly).Returns(new[] { targetDir }); targetDir.GetFiles(filename).Returns(new[] { this.GetFakeFile("tools", "metamorphosator", "addins", filename) }); var expected = new[] { this.GetFakeFile("tools", "metamorphosator", "addins", filename) }; var actual = finder.GetFiles(baseDir, pattern); CollectionAssert.AreEquivalent(expected, actual); targetDir.Received().GetFiles(filename); foreach (var dir in this.fakedDirectories.Values.Where(x => x != targetDir)) { dir.DidNotReceive().GetFiles(Arg.Any <string>()); } targetDir.Received().GetFiles(filename); targetDir.DidNotReceive().GetDirectories(Arg.Any <string>(), Arg.Any <SIO.SearchOption>()); GetFakeDirectory("tools", "frobuscator").DidNotReceive().GetDirectories(Arg.Any <string>(), Arg.Any <SIO.SearchOption>()); }
public void GetDirectories_GreedyThenWordThenGreedy() { var finder = new DirectoryFinder(this.fileSystem); var baseDir = this.GetFakeDirectory("tools"); this.GetFakeDirectory("tools", "frobuscator").GetDirectories("tests", SIO.SearchOption.TopDirectoryOnly).Returns(new[] { this.GetFakeDirectory("tools", "frobuscator", "tests") }); this.GetFakeDirectory("tools", "metamorphosator").GetDirectories("tests", SIO.SearchOption.TopDirectoryOnly).Returns(new[] { this.GetFakeDirectory("tools", "metamorphosator", "tests") }); var expected = new[] { this.GetFakeDirectory("tools", "frobuscator", "tests"), this.GetFakeDirectory("tools", "frobuscator", "tests", "abc"), this.GetFakeDirectory("tools", "frobuscator", "tests", "def"), this.GetFakeDirectory("tools", "metamorphosator", "tests"), this.GetFakeDirectory("tools", "metamorphosator", "tests", "v1"), this.GetFakeDirectory("tools", "metamorphosator", "tests", "v1", "tmp"), this.GetFakeDirectory("tools", "metamorphosator", "tests", "v2") }; var actual = finder.GetDirectories(baseDir, "**/tests/**"); CollectionAssert.AreEquivalent(expected, actual); baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any <string>(), Arg.Any <SIO.SearchOption>()); baseDir.Received().GetDirectories("*", SIO.SearchOption.AllDirectories); this.GetFakeDirectory("tools", "frobuscator").Received().GetDirectories("tests", SIO.SearchOption.TopDirectoryOnly); this.GetFakeDirectory("tools", "metamorphosator").Received().GetDirectories("tests", SIO.SearchOption.TopDirectoryOnly); this.GetFakeDirectory("tools", "frobuscator", "tests").Received().GetDirectories("*", SIO.SearchOption.AllDirectories); this.GetFakeDirectory("tools", "metamorphosator", "tests").Received().GetDirectories("*", SIO.SearchOption.AllDirectories); }
public async Task RecreateWithOpenConnection() { var name = "RecreateWithOpenConnection"; LocalDbApi.StopAndDelete(name); DirectoryFinder.Delete(name); Wrapper wrapper = new(s => new SqlConnection(s), name, DirectoryFinder.Find(name)); wrapper.Start(timestamp, TestDbBuilder.CreateTable); var connectionString = await wrapper.CreateDatabaseFromTemplate("Simple"); await using (SqlConnection connection = new(connectionString)) { await connection.OpenAsync(); wrapper = new(s => new SqlConnection(s), name, DirectoryFinder.Find(name)); wrapper.Start(timestamp, TestDbBuilder.CreateTable); await wrapper.CreateDatabaseFromTemplate("Simple"); } await Verifier.Verify(wrapper.ReadDatabaseState("Simple")); LocalDbApi.StopInstance(name); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Perform a restore of the project specified in the settings. /// </summary> /// <param name="progressDlg">The progress dialog.</param> /// <exception cref="IOException">File does not exist, or some such problem</exception> /// <exception cref="InvalidBackupFileException">XML deserialization problem or required /// files not found in zip file</exception> /// ------------------------------------------------------------------------------------ public void RestoreProject(IThreadedProgress progressDlg) { BackupFileSettings fileSettings = m_restoreSettings.Backup; fileSettings.Validate(); // Normally, this will already have been done, so this will do nothing. bool suppressConversion = false; //First of all, if the project exists and we are overwriting it, then make a copy of the project. That way //if the restoration fails part way through, we can put it back the way it was. if (Directory.Exists(m_restoreSettings.ProjectPath)) { // If the project already exists using the fwdata extension, either we're not sharing, // or it is a project for which sharing is suppressed. In any case we don't want to // convert the new project. suppressConversion = File.Exists(m_restoreSettings.FullProjectPath); CreateACopyOfTheProject(); } //When restoring a project, ensure all the normal folders are there even if some //of those folders had nothing from them in the backup. Directory.CreateDirectory(m_restoreSettings.ProjectPath); FdoCache.CreateProjectSubfolders(m_restoreSettings.ProjectPath); try { //Import from FW version 6.0 based on the file extension. string extension = Path.GetExtension(fileSettings.File).ToLowerInvariant(); if (extension == FwFileExtensions.ksFw60BackupFileExtension || extension == ".xml") { ImportFrom6_0Backup(fileSettings, progressDlg); } else //Restore from FW version 7.0 and newer backup. { RestoreFrom7_0AndNewerBackup(fileSettings); } } catch (Exception error) { if (error is IOException || error is InvalidBackupFileException || error is UnauthorizedAccessException) { CleanupAfterRestore(false); // ENHANCE: If/when we have the restore process using a progress dialog so that this code // runs in the progress dialog thread instead of the main thread, all message boxes should // be replaced with the ThreadHelper.ShowMessageBox() method so that they will be thread-safe. MessageBoxUtils.Show(null, error.Message, AppStrings.ksRestoreDidNotSucceed, MessageBoxButtons.OK, MessageBoxIcon.Information); } throw; } // switch to the desired backend (if it's in the projects directory...anything else stays XML for now). if (DirectoryFinder.IsSubFolderOfProjectsDirectory(m_restoreSettings.ProjectPath) && !suppressConversion) { ClientServerServices.Current.Local.ConvertToDb4oBackendIfNeeded(progressDlg, m_restoreSettings.FullProjectPath); } CleanupAfterRestore(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the available FLEx UI languages. /// </summary> /// ------------------------------------------------------------------------------------ private void AddAvailableFLExUILanguages() { // Now, find which languages have a localized strings-{locale}.xml file. // Allow only those languages which have valid .NET locales to be displayed. string sConfigDir = DirectoryFinder.GetFWCodeSubDirectory(@"Language Explorer\Configuration"); if (!Directory.Exists(sConfigDir)) { return; } string[] rgsFiles = Directory.GetFiles(sConfigDir, "strings-*.xml"); foreach (string file in rgsFiles) { string locale = Path.GetFileNameWithoutExtension(file); int i = locale.LastIndexOf('-'); if (i >= 0) { locale = locale.Substring(i + 1); if (MiscUtils.WsHasValidCulture(locale)) { AddLanguage(locale); } } } }
public async Task NoFileAndWithInstanceAndNamedDb() { var instanceName = "NoFileAndWithInstanceAndNamedDb"; LocalDbApi.StopAndDelete(instanceName); LocalDbApi.CreateInstance(instanceName); DirectoryFinder.Delete(instanceName); Wrapper wrapper = new(s => new SqlConnection(s), instanceName, DirectoryFinder.Find(instanceName)); wrapper.Start(timestamp, TestDbBuilder.CreateTable); await wrapper.AwaitStart(); await wrapper.CreateDatabaseFromTemplate("Simple"); Thread.Sleep(3000); DirectoryFinder.Delete(instanceName); wrapper = new(s => new SqlConnection(s), instanceName, DirectoryFinder.Find(instanceName)); wrapper.Start(timestamp, TestDbBuilder.CreateTable); await wrapper.AwaitStart(); await wrapper.CreateDatabaseFromTemplate("Simple"); await Verifier.Verify(wrapper.ReadDatabaseState("Simple")); }
public Task WithRebuild() { var instance2 = new Wrapper(s => new SqlConnection(s), "WrapperTests", DirectoryFinder.Find("WrapperTests")); instance2.Start(timestamp, connection => throw new Exception()); return(instance2.AwaitStart()); }
/// <summary> /// Return the fullPath for a project's LinkedFiles based on the relative path that was persisted. /// If no match on a relativePath match is made then return the relativePath passed in assuming it /// is actually a full path. /// </summary> /// <param name="projectsPath"></param> /// <param name="relativePath"></param> /// <param name="projectPath"></param> /// <returns></returns> public static String GetLinkedFilesFullPathFromRelativePath(string projectsPath, string relativePath, String projectPath) { String fullPath = null; fullPath = GetFullPathForRelativePath(relativePath, ksProjectRelPath, projectPath); if (String.IsNullOrEmpty(fullPath)) { fullPath = GetFullPathForRelativePath(relativePath, ksProjectsRelPath, projectsPath); } if (String.IsNullOrEmpty(fullPath)) { fullPath = GetFullPathForRelativePath(relativePath, ksCommonAppDataRelPath, DirectoryFinder.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)); } if (String.IsNullOrEmpty(fullPath)) { fullPath = GetFullPathForRelativePath(relativePath, ksMyDocsRelPath, DirectoryFinder.GetFolderPath(Environment.SpecialFolder.MyDocuments)); } if (String.IsNullOrEmpty(fullPath)) { return(FixPathSlashesIfNeeded(relativePath)); } return(FixPathSlashesIfNeeded(fullPath)); }
/// <summary> /// Install Virtual properties from Fieldworks xml configuration. /// </summary> /// <param name="fwInstallFile"></param> /// <param name="assemblyNamespaces">Comma-separated list of class name prefixes (typically namespace including /// trailing period). These are matched against the start of the class attributes of dynamicloaderinfo /// children of virtuals/virtual elements to decide which ones are to be loaded.</param> /// <param name="cache"></param> /// <param name="fSkipMissingFiles">true when it is OK for some include files not to be found.</param> /// <param name="fProcessIncludes">false when you don't want to process configuration includes. helpful for tests /// that don't have knowledge of dlls that will get included.</param> public static List <IVwVirtualHandler> InstallVirtuals(string fwInstallFile, string[] assemblyNamespaces, FdoCache cache, bool fSkipMissingFiles, bool fProcessIncludes) { string configurationFile = DirectoryFinder.GetFWCodeFile(fwInstallFile); XmlDocument configuration = null; if (fProcessIncludes) { configuration = XmlUtils.LoadConfigurationWithIncludes(configurationFile, fSkipMissingFiles); } else { configuration = new XmlDocument(); configuration.Load(configurationFile); } XmlNode virtuals = configuration.CreateElement("virtuals"); // get the nodes in original order, so that they will have proper dependency structure. XmlNodeList virtualNodes = configuration.SelectNodes("//virtuals/virtual/dynamicloaderinfo"); foreach (XmlNode node in virtualNodes) { // filter out the nodes that are not in the requested namespaces foreach (string ns in assemblyNamespaces) { if (node.Attributes["class"].Value.StartsWith(ns)) { virtuals.AppendChild(node.ParentNode); } } } return(InstallVirtuals(virtuals, cache)); }
public async Task NoFileAndNoDb() { LocalDbApi.StopAndDelete("TestDbContext_EfNoFileAndNoDb"); var directory = DirectoryFinder.Find("TestDbContext_EfNoFileAndNoDb"); if (Directory.Exists(directory)) { Directory.Delete(directory, true); } var instance = new SqlInstance <TestDbContext>( constructInstance: builder => new TestDbContext(builder.Options), instanceSuffix: "EfNoFileAndNoDb"); var entity = new TestEntity { Property = "prop" }; using (var database = await instance.Build(new List <object> { entity })) { Assert.NotNull(database.Context.TestEntities.FindAsync(entity.Id)); } }
/// <summary> /// a slice filter is used to hide some slices. /// </summary> /// <remarks> this will set up a filter even if you do not specify a filter path, since /// some filtering is done by the FDO classes (CmObject.IsFieldRelevant) /// </remarks> /// <example> /// to set up a slice filter,kids the relative path in the filterPath attribute of the parameters: /// <control assemblyPath="xWorks.dll" class="SIL.FieldWorks.XWorks.RecordEditView"> /// <parameters field="Entries" templatePath="LexEd\XDEs" filterPath="LexEd\basicFilter.xml"> /// ... ///</example> private void SetupSliceFilter() { try { string filterPath = XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "filterPath"); if (filterPath != null) { #if __MonoCS__ // TODO-Linux: fix the data filterPath = filterPath.Replace(@"\", "/"); #endif var document = new XmlDocument(); document.Load(DirectoryFinder.GetFWCodeFile(filterPath)); m_dataEntryForm.SliceFilter = new SliceFilter(document); } else //just set up a minimal filter { m_dataEntryForm.SliceFilter = new SliceFilter(); } } catch (Exception e) { throw new ConfigurationException("Could not load the filter.", m_configurationParameters, e); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create the mediator if it doesn't already exist. Ensure that the string table in /// the mediator is loaded from the Flex string table. /// </summary> /// <param name="mediator"></param> /// <param name="fRestoreStringTable">output flag that we should restore the original string table</param> /// <param name="stOrig">output is the original string table</param> /// ------------------------------------------------------------------------------------ protected static Mediator EnsureValidMediator(Mediator mediator, out bool fRestoreStringTable, out StringTable stOrig) { if (mediator == null) { mediator = new Mediator(); fRestoreStringTable = false; stOrig = null; } else { try { stOrig = mediator.StringTbl; // Check whether this is the Flex string table: look for a lexicon type // string and compare the value with what is produced when it's not found. string s = stOrig.GetString("MoCompoundRule-Plural", "AlternativeTitles"); fRestoreStringTable = (s == "*MoCompoundRule-Plural*"); } catch { stOrig = null; fRestoreStringTable = true; } } if (fRestoreStringTable || stOrig == null) { string dir = DirectoryFinder.GetFWCodeSubDirectory("Language Explorer\\Configuration"); mediator.StringTbl = new SIL.Utils.StringTable(dir); } return(mediator); }
public SqlInstance( string name, Func <SqlConnection, Task> buildTemplate, string?directory = null, DateTime?timestamp = null, ushort templateSize = 3) { Guard.AgainstNull(nameof(buildTemplate), buildTemplate); Guard.AgainstWhiteSpace(nameof(directory), directory); Guard.AgainstNullWhiteSpace(nameof(name), name); if (directory == null) { directory = DirectoryFinder.Find(name); } DateTime resultTimestamp; if (timestamp == null) { var callingAssembly = Assembly.GetCallingAssembly(); resultTimestamp = Timestamp.LastModified(callingAssembly); } else { resultTimestamp = timestamp.Value; } wrapper = new Wrapper(name, directory, templateSize); wrapper.Start(resultTimestamp, buildTemplate); }
private void UncompressLinkedFiles(Dictionary <String, DateTime> fileList, String destinationLinkedFilesPath, String linkedFilesPathPersisted) { using (var zipIn = OpenFWBackupZipfile()) { ZipEntry entry; while ((entry = zipIn.GetNextEntry()) != null) { //Code to use for restoring files with new file structure. if (fileList.ContainsKey(entry.Name)) { var fileName = Path.GetFileName(entry.Name); Debug.Assert(!String.IsNullOrEmpty(fileName)); //Contruct the path where the file will be unzipped too. var zipFileLinkFilesPath = DirectoryFinder.GetZipfileFormatedPath(linkedFilesPathPersisted); var filenameWithSubFolders = entry.Name.Substring(zipFileLinkFilesPath.Length); var pathForFileSubFolders = filenameWithSubFolders.Substring(1, filenameWithSubFolders.Length - fileName.Length - 1); var destFolderZipFileFormat = DirectoryFinder.GetZipfileFormatedPath(destinationLinkedFilesPath); string pathRoot = Path.GetPathRoot(destinationLinkedFilesPath); Debug.Assert(!String.IsNullOrEmpty(pathRoot)); var pathforfileunzip = Path.Combine(pathRoot, Path.Combine(destFolderZipFileFormat, pathForFileSubFolders)); UnzipFileToRestoreFolder(zipIn, fileName, entry.Size, pathforfileunzip, entry.DateTime); } } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Read the TEStyles.xml file to get the default marker mappings /// </summary> /// ------------------------------------------------------------------------------------ private static void ReadDefaultMappings() { XmlDocument doc = new XmlDocument(); doc.Load(Path.Combine(DirectoryFinder.GetFWCodeSubDirectory("Translation Editor"), "TEStyles.xml")); XmlNode mappingNode = doc.SelectSingleNode("Styles/ImportMappingSets/ImportMapping[@name='TE Default']"); foreach (XmlNode mapNode in mappingNode.SelectNodes("mapping")) { string marker = @"\" + mapNode.Attributes["id"].Value; string type = mapNode.Attributes["type"].Value; if (type == "style") { string styleName = mapNode.Attributes["styleName"].Value.Replace("_", " "); s_defaultMappings.Add(marker, styleName); } else if (type == "property") { s_defaultProperties.Add(marker, mapNode.Attributes["propertyName"].Value); } else if (type == "excluded") { s_defaultExclusions.Add(marker, string.Empty); } } }
static WrapperTests() { LocalDbApi.StopAndDelete("WrapperTests"); instance = new Wrapper(s => new SqlConnection(s), "WrapperTests", DirectoryFinder.Find("WrapperTests")); instance.Start(timestamp, TestDbBuilder.CreateTable); instance.AwaitStart().GetAwaiter().GetResult(); }
public void OnlyOneCacheAllowed() { string filename = DirectoryFinder.GetXmlDataFileName("TestLangProj"); Assert.True(File.Exists(filename), "Test XML file not found"); using (FdoCache cache = OpenExistingFile(filename)) Assert.Fail("Able to open XML file that is already open"); }
private string SettingsPath() { string path = DirectoryFinder.UserAppDataFolder(m_appName); Directory.CreateDirectory(path); path = Path.Combine(path, "DialogResponses.xml"); return(path); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Verifies the file exists in the zip file. /// </summary> /// <param name="zip">The zip file.</param> /// <param name="fileNameAndPath">The file name (with path) to look for.</param> /// ------------------------------------------------------------------------------------ private static void VerifyFileExistsInZipFile(ZipFile zip, String fileNameAndPath) { string str = DirectoryFinder.GetZipfileFormatedPath(fileNameAndPath); //ensure the entry is the correct one. ZipEntry entry = zip.GetEntry(str); Assert.True(entry.Name.Equals(str), String.Format("File {0} should exist in zipFile", str)); }
public void Run() { LocalDbApi.StopAndDelete("DanglingLogWrapperTests"); var instance = new Wrapper(s => new SqlConnection(s), "WrapperTests", DirectoryFinder.Find("DanglingLogWrapperTests")); base.Dispose(); instance.Start(DateTime.Now, TestDbBuilder.CreateTable); }
public void Run() { var name = "DanglingLogWrapperTests"; LocalDbApi.StopAndDelete(name); Wrapper instance = new(s => new SqlConnection(s), name, DirectoryFinder.Find(name)); instance.Start(DateTime.Now, TestDbBuilder.CreateTable); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor /// </summary> /// <param name="backupProjectView">The backup project dialog box.</param> /// <param name="appAbbrev">The command-line abbreviation for the application displaying /// this backup dialog box.</param> /// <param name="cache">The cache.</param> /// ------------------------------------------------------------------------------------ internal BackupProjectPresenter(IBackupProjectView backupProjectView, string appAbbrev, FdoCache cache) { m_cache = cache; m_appAbbrev = appAbbrev; m_backupProjectView = backupProjectView; //Older projects might not have this folder so when launching the backup dialog we want to create it. Directory.CreateDirectory(DirectoryFinder.GetSupportingFilesDir(m_cache.ProjectId.ProjectFolder)); }
public async Task NoFileAndWithInstance() { LocalDbApi.CreateInstance("NoFileAndWithInstance"); DirectoryFinder.Delete("NoFileAndWithInstance"); var instance = new SqlInstance("NoFileAndWithInstance", TestDbBuilder.CreateTable); await AddAndVerifyData(instance); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Use this for slow operations that should happen during the splash screen instead of /// during app construction /// </summary> /// ------------------------------------------------------------------------------------ protected override void DoApplicationInitialization() { base.DoApplicationInitialization(); CleanupRegistry(); CleanupOldFiles(); //InitializeMessageDialogs(); ScrReference.InitializeVersification(DirectoryFinder.GetFWCodeSubDirectory( "Translation Editor"), false); }
void IFwExtension.Init(FdoCache cache, Mediator mediator) { updateGlobalWS.Checked = !CoreImpl.Properties.Settings.Default.UpdateGlobalWSStore; m_mediator = mediator; m_cache = cache; m_helpTopicProvider = mediator.HelpTopicProvider; m_sUserWs = m_cache.ServiceLocator.WritingSystemManager.UserWritingSystem.Id; m_sNewUserWs = m_sUserWs; m_userInterfaceChooser.Init(m_sUserWs); // Populate Plugins tab page list. var baseConfigPath = DirectoryFinder.GetFWCodeSubDirectory( Path.Combine("Language Explorer", "Configuration")); string basePluginPath = Path.Combine(baseConfigPath, "Available Plugins"); // The extension XML files should be stored in the data area, not in the code area. // This reduces the need for users to have administrative privileges. string baseExtensionPath = Path.Combine(DirectoryFinder.FWDataDirectory, Path.Combine("Language Explorer", "Configuration")); foreach (string dir in Directory.GetDirectories(basePluginPath)) { Debug.WriteLine(dir); // Currently not offering Concorder plugin in FW7, therefore, we // can remove the feature until we need to implement. (FWNX-755) if (MiscUtils.IsUnix && dir == Path.Combine(basePluginPath, "Concorder")) { continue; } string managerPath = Path.Combine(dir, "ExtensionManager.xml"); if (File.Exists(managerPath)) { XmlDocument managerDoc = new XmlDocument(); managerDoc.Load(managerPath); XmlNode managerNode = managerDoc.SelectSingleNode("/manager"); m_lvPlugins.SuspendLayout(); ListViewItem lvi = new ListViewItem(); lvi.Tag = managerDoc; lvi.Text = managerNode.Attributes["name"].Value; lvi.SubItems.Add(managerNode.Attributes["description"].Value); // See if it is installed and check the lvi if it is. XmlNode configfilesNode = managerNode.SelectSingleNode("configfiles"); string extensionPath = Path.Combine(baseExtensionPath, configfilesNode.Attributes["targetdir"].Value); lvi.Checked = Directory.Exists(extensionPath); m_plugins.Add(lvi.Text, lvi.Checked); // Remember original installed state. m_lvPlugins.Items.Add(lvi); m_lvPlugins.ResumeLayout(); } } if (m_helpTopicProvider != null) // Will be null when running tests { helpProvider = new HelpProvider(); helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile; helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic)); helpProvider.SetHelpNavigator(this, HelpNavigator.Topic); } }
public async Task DefinedTimestamp() { var instance2 = new Wrapper(s => new SqlConnection(s), "DefinedTimestamp", DirectoryFinder.Find("DefinedTimestamp")); var dateTime = DateTime.Now; instance2.Start(dateTime, connection => Task.CompletedTask); await instance2.AwaitStart(); Assert.Equal(dateTime, File.GetCreationTime(instance2.TemplateDataFile)); }
public void GetDirectories_PatternIsEmpty() { var directory = Substitute.For <IDirectory>(); var sut = new DirectoryFinder(Substitute.For <IFileSystem>()); var directories = sut.GetDirectories(directory, string.Empty); Assert.That(directories, Has.Count.EqualTo(1)); Assert.That(directories.First(), Is.EqualTo(directory)); }
private static string GetJnlPath() { var files = new DirectoryFinder("/", "*.jnl").List; return string.Join(", ", files).ToString(); }
private static string GetPath() { var dbName = CoreParametersConfig.GetAntdDb(); var directories = new DirectoryFinder("/", dbName).List; return string.Join(", ", directories).ToString(); }