示例#1
0
 public void Constructor_CreateNewProjectFromBundle_BundleHasNoLdmlFile_WsIsoIsSet_ProjectIsCreatedSuccessfully()
 {
     Sldr.Initialize();
     try
     {
         var bundle = GetGlyssenBundleToBeUsedForProject(false);
         bundle.Metadata.Language.Ldml = "";
         bundle.Metadata.Language.Iso  = "ach";
         bundle.Metadata.Language.Name = "Acholi";                 // see messages in Assert.AreEqual lines below
         var project = new Project(bundle);
         m_tempProjectFolders.Add(Path.GetDirectoryName(Path.GetDirectoryName(project.ProjectFilePath)));
         WaitForProjectInitializationToFinish(project, ProjectState.ReadyForUserInteraction);
         Assert.IsNotNull(project);
         Assert.IsNotEmpty(project.QuoteSystem.AllLevels);
         Assert.AreEqual("ach", project.WritingSystem.Id);
         Assert.AreEqual("Acoli", project.WritingSystem.Language.Name,
                         "This name should be coming from the \"global\" cache, not from the metadata above - note spelling difference.");
         Assert.AreEqual("ach", project.WritingSystem.Language.Iso3Code,
                         "If \"ach\" is not found in the global cache, the lnaguage subtag will be considered \"private-use\" and the " +
                         "ISO code will be null");
         Assert.AreEqual("ach", project.WritingSystem.Language.Code);
     }
     finally
     {
         Sldr.Cleanup();
     }
 }
        public void LoadProject(string projectName)
        {
            LCModel.Core.Text.CustomIcu.InitIcuDataDir();
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize(true);
            }
            var dirs        = new PaFieldWorksHelper();
            var projectPath = string.Empty;

            if (File.Exists(projectName))
            {
                projectPath = projectName;
            }
            else
            {
                projectPath = Path.Combine(dirs.ProjectsDirectory, projectName, projectName + LcmFileHelper.ksFwDataXmlFileExtension);
            }

            var ui       = new SilentLcmUI(SynchronizeInvoke);
            var settings = new LcmSettings {
                DisableDataMigration = false, UpdateGlobalWSStore = false
            };

            SilTools.Utils.WaitCursors(true);
            using (var progressDlg = new PAProgress())
            {
                m_cache = LcmCache.CreateCacheFromExistingData(new FWProjectId(BackendProviderType.kSharedXML, projectPath), Thread.CurrentThread.CurrentUICulture.Name, ui, dirs, settings, progressDlg);
            }
            SilTools.Utils.WaitCursors(false);
        }
示例#3
0
        public void GetLdmlFile_SldrCacheDestinationPath_ReturnsCacheFile()
        {
            using (var environment = new TestEnvironment(false))
            {
                string       filename;
                const string ietfLanguageTag = "en-GB";

                var sldrStatus = Sldr.GetLdmlFile(Sldr.SldrCachePath, ietfLanguageTag, new[] { "characters" }, out filename);
                if (sldrStatus == SldrStatus.UnableToConnectToSldr)
                {
                    Assert.Ignore("Ignored becuase SLDR is offline.");
                }

                Assert.That(sldrStatus, Is.EqualTo(SldrStatus.FromSldr));

                string filePath = Path.Combine(Sldr.SldrCachePath, filename);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/language[@type='en']", environment.NamespaceManager);
                AssertThatXmlIn.File(filePath).HasNoMatchForXpath("/ldml/identity/script", environment.NamespaceManager);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/territory[@type='GB']", environment.NamespaceManager);

                // Verify draft is approved and uid doesn't exist
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[@draft='approved']", environment.NamespaceManager);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[not(@uid)]", environment.NamespaceManager);
            }
        }
 public void FixtureSetup()
 {
     if (!Sldr.IsInitialized)
     {
         Sldr.Initialize();
     }
 }
示例#5
0
        public CallerSetting()
        {
            _xDoc.RemoveAll();
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize(true);
            }
            WritingSystem = new WritingSystemDefinition();
            Caller        = DataCreator.Creator;
            switch (Caller)
            {
            case DataCreator.CreatorProgram.Paratext8:
                _dataFolder = RegistryHelperLite.FallbackStringValue("Paratext/8", "Settings_Directory");
                break;

            case DataCreator.CreatorProgram.Paratext7:
                _dataFolder = RegistryHelperLite.FallbackStringValue("ScrChecks/1.0/Settings_Directory");
                break;

            case DataCreator.CreatorProgram.FieldWorks8:
                _dataFolder = RegistryHelperLite.FallbackStringValue("SIL/FieldWorks/8", "ProjectsDir");
                SetupLdmlFolder();
                break;

            case DataCreator.CreatorProgram.FieldWorks9:
                _dataFolder = RegistryHelperLite.FallbackStringValue("SIL/FieldWorks/9", "ProjectsDir");
                SetupLdmlFolder();
                break;
            }
            if (Caller != DataCreator.CreatorProgram.Unknown)
            {
                return;
            }
            FindDataFolder();
        }
示例#6
0
        public void ReadSilIdentity_GetsRevidAndUid()
        {
            using (var environment = new TestEnvironment())
            {
                string content =
                    @"<?xml version='1.0' encoding='utf-8'?>
<ldml>
	<identity>
		<version number='$Revision: 11161 $'/>
		<generation date='$Date: 2015-01-30 22:33 +0000 $'/>
		<language type='en'/>
		<special xmlns:sil='urn://www.sil.org/ldml/0.1'>
			<sil:identity source='cldr' draft='proposed' revid='53d542ba498f40f437f7723e69dcf64dab6c9794' uid='e2ccb575'/>
		</special>
		<script type='Latn'/>
	</identity>
</ldml>".Replace("\'", "\"");
                const string ietfLanguageTag = "en";
                string       filename        = Path.Combine(environment.FilePath, ietfLanguageTag + ".ldml");
                File.WriteAllText(filename, content);

                string revid, uid;
                Assert.True(Sldr.ReadSilIdentity(filename, out revid, out uid));
                Assert.That(revid, Is.EqualTo("53d542ba498f40f437f7723e69dcf64dab6c9794"));
                Assert.That(uid, Is.EqualTo("e2ccb575"));
            }
        }
示例#7
0
        public void MoveTmpToCache_DraftProposed_KeepsUid()
        {
            using (var environment = new TestEnvironment())
            {
                string content =
                    @"<?xml version='1.0' encoding='utf-8'?>
<ldml>
	<identity>
		<version number='$Revision: 11161 $'/>
		<generation date='$Date: 2015-01-30 22:33 +0000 $'/>
		<language type='en'/>
		<special xmlns:sil='urn://www.sil.org/ldml/0.1'>
			<sil:identity source='cldr' draft='proposed' revid='53d542ba498f40f437f7723e69dcf64dab6c9794' uid='e2ccb575'/>
		</special>
		<script type='Latn'/>
	</identity>
</ldml>".Replace("\'", "\"");
                const string ietfLanguageTag = "en";
                string       filename        = Path.Combine(environment.FilePath, ietfLanguageTag + ".ldml.tmp");
                File.WriteAllText(filename, content);

                Sldr.MoveTmpToCache(filename, "e2ccb575");
                // uid appended to filename and uid attribute preserved
                filename = Path.Combine(environment.FilePath, ietfLanguageTag + "-e2ccb575.ldml");
                AssertThatXmlIn.File(filename).HasAtLeastOneMatchForXpath("/ldml/identity/language[@type='en']", environment.NamespaceManager);
                AssertThatXmlIn.File(filename).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[@revid='53d542ba498f40f437f7723e69dcf64dab6c9794']", environment.NamespaceManager);
                AssertThatXmlIn.File(filename).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[@uid='e2ccb575']", environment.NamespaceManager);
            }
        }
示例#8
0
        public void SetUp()
        {
            // Force initialization in ILRepacked SIL.WritingSystems assembly,
            // even if a referenced SIl.WritingSystems assembly somewhere down
            // the dependency chain, that we won't be using, was initialized.
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize();
            }

            FwRegistryHelper.Initialize();
            m_threadHelper = new ThreadHelper();
            var ui        = new DummyLcmUI(m_threadHelper);
            var projectId = new ParatextLexiconPluginProjectId(BackendProviderType.kMemoryOnly, "Test.fwdata");

            m_cache = LcmCache.CreateCacheWithNewBlankLangProj(projectId, "en", "fr", "en", ui,
                                                               ParatextLexiconPluginDirectoryFinder.LcmDirectories, new LcmSettings());
            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);
        }
示例#9
0
 public void GetLdmlFile_DefaultDownloadsAllTopLevelElements()
 {
     using (var environment = new TestEnvironment(false))
     {
         string       filename;
         const string ietfLanguageTag = "en-US";
         var          sldrStatus      = Sldr.GetLdmlFile(environment.FilePath, ietfLanguageTag, out filename);
         if (sldrStatus == SldrStatus.UnableToConnectToSldr)
         {
             Assert.Ignore("Ignored becuase SLDR is offline.");
         }
         Assert.That(sldrStatus, Is.EqualTo(SldrStatus.FromSldr));
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[identity]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[localeDisplayNames]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[layout]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[contextTransforms]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[characters]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[delimiters]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[dates]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[numbers]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[units]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[listPatterns]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[collations]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[posix]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[segmentations]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[metadata]", environment.NamespaceManager);
     }
 }
示例#10
0
        public void GetLdmlFile_SldrStagingEnvironmentVariable_UsesStagingUrl()
        {
            var originalStagingValue = Environment.GetEnvironmentVariable(Sldr.SldrStaging);

            Environment.SetEnvironmentVariable(Sldr.SldrStaging, "true");
            StringAssert.Contains("&staging=1", Sldr.BuildLdmlRequestUrl("en", "", "", ""));
            Environment.SetEnvironmentVariable(Sldr.SldrStaging, originalStagingValue);
        }
示例#11
0
 protected static void IcuInit()
 {
     Icu.InitIcuDataDir();
     if (!Sldr.IsInitialized)
     {
         Sldr.Initialize();
     }
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParatextMigrationOperations"/> class.
 /// </summary>
 public ParatextMigrationOperations()
 {
     if (!Sldr.IsInitialized)
     {
         // Always use offline mode in tests
         Sldr.Initialize(true);
     }
 }
        public void TestFixtureTearDown()
        {
            Sldr.Cleanup();
            var ntBooks = SilBooks.Codes_3Letter.Skip(39).ToArray();

            if (m_results.Count == 27 || m_results.Count == 1)
            {
                foreach (var bookCode in ntBooks)
                {
                    CastSizeRowValues validCast;
                    if (m_results.TryGetValue(bookCode, out validCast))
                    {
                        Debug.WriteLine("[TestCase(\"" + bookCode + "\", " + (validCast.Male - 1) + ")]");
                    }
                }
                Debug.WriteLine("****************");
            }
            else
            {
                Debug.WriteLine("WARNING: not all NT books are included in these results!!!!!!!!!!!");
            }

            Debug.WriteLine("Copy and paste the following into the CastSizePlanningViewModel constructor:");
            Debug.WriteLine("");

            foreach (var bookCode in ntBooks)
            {
                CastSizeRowValues validCast;
                if (m_results.TryGetValue(bookCode, out validCast))
                {
                    Debug.WriteLine("case \"" + bookCode + "\":");
                    if (bookCode == "HEB")
                    {
                        Debug.WriteLine("switch (m_project.DramatizationPreferences.ScriptureQuotationsShouldBeSpokenBy)");
                        Debug.WriteLine("{");
                        Debug.WriteLine("\tcase DramatizationOption.DedicatedCharacter:");
                        Debug.WriteLine("\t\tsmallCast.Male = Math.Max(smallCast.Male, 1);");
                        Debug.WriteLine("\t\tbreak;");
                        Debug.WriteLine("\tcase DramatizationOption.DefaultCharacter:");
                        Debug.WriteLine("\t\tsmallCast.Male = Math.Max(smallCast.Male, 4);");
                        Debug.WriteLine("\t\tbreak;");
                        Debug.WriteLine("\tcase DramatizationOption.Narrator:");
                        Debug.WriteLine("\t\tsmallCast.Male = Math.Max(smallCast.Male, 0);");
                        Debug.WriteLine("\t\tbreak;");
                        Debug.WriteLine("}");
                    }
                    else
                    {
                        Debug.WriteLine("smallCast.Male = Math.Max(smallCast.Male, " + (validCast.Male - 2) + ");");
                    }
                    if (validCast.Female != 2)
                    {
                        Debug.WriteLine("smallCast.Female = " + validCast.Female + ";");
                    }
                    Debug.WriteLine("break;");
                }
            }
        }
示例#14
0
        public LiftService()
        {
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize(true);
            }

            _liftExports = new Dictionary <string, string>();
        }
示例#15
0
        static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                WriteHelp();
                return(0);
            }

            if (!File.Exists(args[0]))
            {
                Console.WriteLine("The FieldWorks project file could not be found.");
                return(1);
            }

            FwRegistryHelper.Initialize();
            FwUtils.InitializeIcu();
            Sldr.Initialize();
            var synchronizeInvoke = new SingleThreadedSynchronizeInvoke();
            var spanFactory       = new ShapeSpanFactory();

            var projectId = new ProjectIdentifier(args[0]);
            var logger    = new ConsoleLogger(synchronizeInvoke);
            var dirs      = new NullFdoDirectories();
            var settings  = new LcmSettings {
                DisableDataMigration = true
            };
            var progress = new NullThreadedProgress(synchronizeInvoke);

            Console.WriteLine("Loading FieldWorks project...");
            try
            {
                using (LcmCache cache = LcmCache.CreateCacheFromExistingData(projectId, "en", logger, dirs, settings, progress))
                {
                    Language language = HCLoader.Load(spanFactory, cache, logger);
                    Console.WriteLine("Loading completed.");
                    Console.WriteLine("Writing HC configuration file...");
                    XmlLanguageWriter.Save(language, args[1]);
                    Console.WriteLine("Writing completed.");
                }
                return(0);
            }
            catch (LcmFileLockedException)
            {
                Console.WriteLine("Loading failed.");
                Console.WriteLine("The FieldWorks project is currently open in another application.");
                Console.WriteLine("Close the application and try to run this command again.");
                return(1);
            }
            catch (LcmDataMigrationForbiddenException)
            {
                Console.WriteLine("Loading failed.");
                Console.WriteLine("The FieldWorks project was created with an older version of FLEx.");
                Console.WriteLine("Migrate the project to the latest version by opening it in FLEx.");
                return(1);
            }
        }
示例#16
0
        public void GetLdmlFile_EmptyPath_Throws()
        {
            string       path            = string.Empty;
            const string ietfLanguageTag = "en";
            string       filename;

            Assert.Throws <ArgumentException>(
                () => Sldr.GetLdmlFile(path, ietfLanguageTag, out filename)
                );
        }
示例#17
0
        public void GetLdmlFile_BadDirName_Throws()
        {
            const string path            = "/dev/null/";
            const string ietfLanguageTag = "en";
            string       filename;

            Assert.Throws <DirectoryNotFoundException>(
                () => Sldr.GetLdmlFile(path, ietfLanguageTag, out filename)
                );
        }
示例#18
0
        public static void Main(string[] args)
        {
            ExceptionLogging.Initialize("17a42e4a67dd2e42d4aa40d8bf2d23ee", Assembly.GetExecutingAssembly().GetName().Name);
            var options = AuxToolOptions.ParseCommandLineArgs(args);

            if (options == null)
            {
                return;
            }

            if (!File.Exists(options.Project))
            {
                Console.WriteLine("Can't find project file '{0}'", options.Project);
                return;
            }

            Icu.Wrapper.Init();

            // initialize the SLDR
            Sldr.Initialize();

            try
            {
                var projectFileInfo = new FileInfo(options.Project);
                options.Project = projectFileInfo.FullName;

                if (options.InfoOnly)
                {
                    DisplayInfo(options);
                }

                ExceptionLogging.Client.AddInfo(options.Project,
                                                FwProject.GetModelVersion(options.Project));

                if (options.Migrate)
                {
                    MigrateData(options);
                }

                if (options.Commit)
                {
                    CommitData(options);
                }
            }
            finally
            {
                if (Sldr.IsInitialized)
                {
                    Sldr.Cleanup();
                }

                Icu.Wrapper.Cleanup();
            }
        }
        public void TestFixtureSetUp()
        {
            // Use the real version of the file because we want the results to be based on the production control file.
            ControlCharacterVerseData.TabDelimitedCharacterVerseData = null;
            CharacterDetailData.TabDelimitedCharacterDetailData      = null;

            Sldr.Initialize();
            m_project = Project.Load(@"C:\ProgramData\FCBH-SIL\Glyssen\ach\3b9fdc679b9319c3\Acholi New Test 1985 Audio\ach.glyssen");
            TestProject.SimulateDisambiguationForAllBooks(m_project);
            m_project.CharacterGroupGenerationPreferences.NarratorsOption = NarratorsOption.SingleNarrator;
        }
示例#20
0
 public void Dispose()
 {
     if (Sldr.IsInitialized)
     {
         Sldr.Cleanup();
     }
     if (Directory.Exists(_ldmlFolder))
     {
         Directory.Delete(_ldmlFolder, true);
     }
 }
        public void TestFixtureSetUp()
        {
            // Use the real version of the file because we want the results to be based on the production control file.
            ControlCharacterVerseData.TabDelimitedCharacterVerseData = null;
            CharacterDetailData.TabDelimitedCharacterDetailData      = null;

            Sldr.Initialize();
            //Change this to Kuna and finish tests for OT books
            m_project = Project.Load(@"C:\ProgramData\FCBH-SIL\Glyssen\cuk\5a6b88fafe1c8f2b\The Bible in Kuna, San Blas Audio (1)\cuk.glyssen");
            TestProject.SimulateDisambiguationForAllBooks(m_project);
            m_project.CharacterGroupGenerationPreferences.NarratorsOption = NarratorsOption.SingleNarrator;
        }
示例#22
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FwRegistryHelper.Initialize();
            FwUtils.InitializeIcu();
            Sldr.Initialize();
            using (var form = new LCMBrowserForm())
            {
                Application.Run(form);
            }

            Sldr.Cleanup();
        }
示例#23
0
            public void Dispose()
            {
                FolderContainingLdml.Dispose();
                string sldrCachePath = Sldr.SldrCachePath;

                Sldr.Cleanup();
                // clear out SLDR cache
                DirectoryInfo di = new DirectoryInfo(sldrCachePath);

                foreach (FileInfo fi in di.GetFiles())
                {
                    fi.Delete();
                }
                // The OfflineSldrAttribute has been assigned to the entire test assembly, so we reinitialize
                // the SLDR back to what it was
                Sldr.Initialize(true, sldrCachePath);
            }
示例#24
0
            public TestEnvironment(bool sldrOffline = true, DateTime?embeddedAllTagsTime = null)
            {
                string sldrCachePath = Sldr.SldrCachePath;

                Sldr.Cleanup();
                if (embeddedAllTagsTime == null)
                {
                    Sldr.Initialize(sldrOffline, sldrCachePath);
                }
                else
                {
                    Sldr.Initialize(sldrOffline, sldrCachePath, embeddedAllTagsTime.Value);
                }
                FolderContainingLdml = new TemporaryFolder("SldrTests");
                NamespaceManager     = new XmlNamespaceManager(new NameTable());
                NamespaceManager.AddNamespace("sil", "urn://www.sil.org/ldml/0.1");
            }
示例#25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FwLexiconPlugin"/> class.
        /// </summary>
        public FwLexiconPlugin()
        {
            FwRegistryHelper.Initialize();

            // 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" + CustomIcu.Version);
#if DEBUG
                    string icuDataPath = codeIcuDataPath;
#else
                    string icuDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), ".config/fieldworks/Icu" + CustomIcu.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);
                }
            }
            FwUtils.InitializeIcu();
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize();
            }

            m_syncRoot     = new object();
            m_lexiconCache = new FdoLexiconCollection();
            m_cacheCache   = new LcmCacheCollection();
            m_ui           = new ParatextLexiconPluginLcmUI();
        }
示例#26
0
 public void Constructor_CreateNewProjectFromBundle_BundleHasNoLdmlFile_WsLdmlIsSet_ProjectIsCreatedSuccessfully()
 {
     Sldr.Initialize();
     try
     {
         var bundle = GetGlyssenBundleToBeUsedForProject(false);
         bundle.Metadata.Language.Ldml = "ach";
         var project = new Project(bundle);
         WaitForProjectInitializationToFinish(project, ProjectState.ReadyForUserInteraction);
         Assert.IsNotNull(project);
         Assert.IsNotEmpty(project.QuoteSystem.AllLevels);
         Assert.AreEqual("ach", project.WritingSystem.Id);
     }
     finally
     {
         Sldr.Cleanup();
     }
 }
示例#27
0
        /// <summary>
        /// Override to dispose managed resources.
        /// </summary>
        protected override void DisposeManagedResources()
        {
            lock (m_syncRoot)
            {
                foreach (FdoLexicon lexicon in m_lexiconCache)
                {
                    lexicon.Dispose();
                }
                m_lexiconCache.Clear();
                foreach (LcmCache fdoCache in m_cacheCache)
                {
                    fdoCache.ServiceLocator.GetInstance <IUndoStackManager>().Save();
                    fdoCache.Dispose();
                }
                m_cacheCache.Clear();
            }

            Sldr.Cleanup();
        }
示例#28
0
 public void Constructor_CreateNewProjectFromBundle_BundleHasNoLdmlFile_WsIsoCodeNotInLanguageRepo_ProjectIsCreatedUsingPrivateUseWritingSystem()
 {
     Sldr.Initialize();
     try
     {
         var bundle = GetGlyssenBundleToBeUsedForProject(false);
         bundle.Metadata.Language.Iso  = "zyt";
         bundle.Metadata.Language.Ldml = "";
         var project = new Project(bundle);
         WaitForProjectInitializationToFinish(project, ProjectState.ReadyForUserInteraction);
         Assert.IsNotNull(project);
         Assert.IsNotEmpty(project.QuoteSystem.AllLevels);
         Assert.AreEqual("zyt", project.WritingSystem.Id);
         Assert.IsTrue(project.WritingSystem.Language.IsPrivateUse);
     }
     finally
     {
         Sldr.Cleanup();
     }
 }
        public void TestFixtureTearDown()
        {
            Sldr.Cleanup();

            var otBooks = SilBooks.Codes_3Letter.Take(39).ToArray();

            if (m_results.Count == 39 || m_results.Count == 1)
            {
                foreach (var bookCode in otBooks)
                {
                    CastSizeRowValues validCast;
                    if (m_results.TryGetValue(bookCode, out validCast))
                    {
                        Debug.WriteLine("[TestCase(\"" + bookCode + "\", " + (validCast.Male - 1) + ")]");
                    }
                }
                Debug.WriteLine("****************");
            }
            else
            {
                Debug.WriteLine("WARNING: not all OT books are included in these results!!!!!!!!!!!");
            }

            Debug.WriteLine("Copy and paste the following into the CastSizePlanningViewModel constructor:");
            Debug.WriteLine("");

            foreach (var bookCode in otBooks)
            {
                CastSizeRowValues validCast;
                if (m_results.TryGetValue(bookCode, out validCast))
                {
                    Debug.WriteLine("case \"" + bookCode + "\":");
                    Debug.WriteLine("smallCast.Male = Math.Max(smallCast.Male, " + (validCast.Male - 2) + ");");
                    if (validCast.Female != 2)
                    {
                        Debug.WriteLine("smallCast.Female = " + validCast.Female + ";");
                    }
                    Debug.WriteLine("break;");
                }
            }
        }
示例#30
0
        public void TestFixtureSetUp()
        {
            // Use the real version of the file because we want the results to be based on the production control file.
            ControlCharacterVerseData.TabDelimitedCharacterVerseData = null;
            CharacterDetailData.TabDelimitedCharacterDetailData      = null;

            Sldr.Initialize();
            try
            {
                m_project =
                    Project.Load(@"C:\ProgramData\FCBH-SIL\Glyssen\ach\3b9fdc679b9319c3\Acholi New Test 1985 Audio\ach.glyssen");
                TestProject.SimulateDisambiguationForAllBooks(m_project);
                m_project.CharacterGroupGenerationPreferences.NarratorsOption = NarratorsOption.SingleNarrator;
            }
            catch
            {
                // If we have an exception here, TestFixtureTearDown doesn't get called which means we need to call Sldr.Cleanup() now
                Sldr.Cleanup();
                throw;
            }
        }