Exemplo n.º 1
0
        public void CreateNewLangProject_AnthropologyCategoriesExist()
        {
            const string dbName = "AnthropologicalTest";

            SureRemoveDb(dbName);
            var preExistingDirs = new List <string>(Directory.GetDirectories(FwDirectoryFinder.ProjectsDirectory));

            try
            {
                // create project
                string dbFileName;
                using (var threadHelper = new ThreadHelper())
                    dbFileName = FdoCache.CreateNewLangProj(new DummyProgressDlg(), dbName, FwDirectoryFinder.FdoDirectories, threadHelper);

                using (var cache = FdoCache.CreateCacheFromLocalProjectFile(dbFileName, "en", m_ui, FwDirectoryFinder.FdoDirectories, new FdoSettings(), new DummyProgressDlg()))
                {
                    Assert.AreEqual(Strings.ksAnthropologyCategories, cache.LangProject.AnthroListOA.Name.UiString,
                                    "Anthropology Categories list was not properly initialized.");
                    Assert.AreEqual(Strings.ksAnth, cache.LangProject.AnthroListOA.Abbreviation.UiString,
                                    "Anthropology Categories list abrv was not properly initialized.");
                    Assert.AreNotEqual(0, cache.LangProject.AnthroListOA.ItemClsid,
                                       "Anthropology Categories list class ID was not properly initialized.");
                    Assert.AreNotEqual(0, cache.LangProject.AnthroListOA.Depth,
                                       "Anthropology Categories list depth was not properly initialized.");
                }
            }
            finally
            {
                RemoveTestDirs(preExistingDirs, Directory.GetDirectories(FwDirectoryFinder.ProjectsDirectory));
            }
        }
        /// <summary>
        /// Method with signature required by ProgressDialogWithTask.RunTask to create the project (and a cache for it)
        /// as a background task while showing the dialog.
        /// </summary>
        /// <param name="progress"></param>
        /// <param name="parameters">A specific list is required...see the first few lines of the method.</param>
        /// <returns></returns>
        private static object CreateProjectTask(IThreadedProgress progress, object[] parameters)
        {
            // Get required parameters. Ideally these would just be the signature of the method, but RunTask requires object[].
            string liftPath      = (string)parameters[0];
            string projectName   = (string)parameters[1];
            var    helper        = (ThreadHelper)parameters[2];
            var    cacheReceiver = (FdoCache[])parameters[3];

            IWritingSystem wsVern, wsAnalysis;

            RetrieveDefaultWritingSystemsFromLift(liftPath, out wsVern, out wsAnalysis);

            string projectPath = FdoCache.CreateNewLangProj(progress, projectName, helper, wsAnalysis, wsVern);

            // This is a temporary cache, just to do the import, and AFAIK we have no access to the current
            // user WS. So create it as "English". Put it in the array to return to the caller.
            cacheReceiver[0] = FdoCache.CreateCacheFromLocalProjectFile(projectPath, "en", progress);
            return(projectPath);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method with signature required by ProgressDialogWithTask.RunTask to create the project (and a cache for it)
        /// as a background task while showing the dialog.
        /// </summary>
        /// <param name="progress"></param>
        /// <param name="parameters">A specific list is required...see the first few lines of the method.</param>
        /// <returns></returns>
        private static object CreateProjectTask(IThreadedProgress progress, object[] parameters)
        {
            // Get required parameters. Ideally these would just be the signature of the method, but RunTask requires object[].
            var liftPathname      = (string)parameters[0];
            var synchronizeInvoke = (ISynchronizeInvoke)parameters[1];
            var anthroFile        = (string)parameters[2];
            var cacheReceiver     = (FdoCache[])parameters[3];

            IWritingSystem wsVern, wsAnalysis;

            RetrieveDefaultWritingSystemsFromLift(liftPathname, out wsVern, out wsAnalysis);

            string projectPath = FdoCache.CreateNewLangProj(progress,
                                                            Directory.GetParent(Path.GetDirectoryName(liftPathname)).Parent.Name, // Get the new Flex project name from the Lift pathname.
                                                            FwDirectoryFinder.FdoDirectories, synchronizeInvoke, wsAnalysis, wsVern, null, null, null, anthroFile);

            // This is a temporary cache, just to do the import, and AFAIK we have no access to the current
            // user WS. So create it as "English". Put it in the array to return to the caller.
            cacheReceiver[0] = FdoCache.CreateCacheFromLocalProjectFile(projectPath, "en", new SilentFdoUI(synchronizeInvoke), FwDirectoryFinder.FdoDirectories, new FdoSettings(), progress);
            return(projectPath);
        }