EnsureDictionary() public static method

Make sure that a dictionary exists for the specified writing system. Currently this will NOT do so if its spelling ID is set to None (in angle brackets). Callers may want to include code like this: var wsObj = Cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem; if (wsObj.SpellCheckingId == "None") // add angle brackets around None wsObj.SpellCheckingId = wsObj.Id.Replace('-', '_'); Enhance JohnT: maybe code like that should be part of this method? But it is meant to just make sure the dictionary exists, once the right SpellCheckingId has been established.
public static EnsureDictionary ( int ws, ILgWritingSystemFactory wsf ) : ISpellEngine
ws int
wsf ILgWritingSystemFactory
return ISpellEngine
Esempio n. 1
0
        public void EnsureDictionaryDoesNotOverwriteNonVernacularDictionary()
        {
            const string dictId   = "nonvern";
            const string testWord = "testWord";

            Directory.CreateDirectory(SpellingHelper.GetSpellingDirectoryPath());
            var filePath = SpellingHelper.GetDicPath(SpellingHelper.GetSpellingDirectoryPath(), dictId);

            // Wipe out any files related to our fake test dictionary
            File.Delete(SpellingHelper.GetExceptionFileName(filePath));
            File.Delete(filePath);
            File.Delete(Path.ChangeExtension(filePath, ".aff"));

            //build new fake test dictionary that is not vernacular
            var nonverndict = @"10" + Environment.NewLine + testWord + Environment.NewLine;
            var nonvernaff  = @"SET UTF-8" + Environment.NewLine + "KEEPCASE C" + Environment.NewLine;

            File.WriteAllText(filePath, nonverndict);
            File.WriteAllText(Path.ChangeExtension(filePath, ".aff"), nonvernaff);
            //SUT
            SpellingHelper.EnsureDictionary(dictId);
            //read back the hopefully unaffected dictionary
            var contents = File.ReadAllText(filePath);

            Assert.That(contents, Is.Not.StringContaining(SpellingHelper.PrototypeWord));
            Assert.That(contents, Contains.Substring(testWord));
        }
Esempio n. 2
0
        private static string MakeEmptyDictionary(string dictId)
        {
            Directory.CreateDirectory(SpellingHelper.GetSpellingDirectoryPath());
            var filePath = SpellingHelper.GetDicPath(SpellingHelper.GetSpellingDirectoryPath(), dictId);

            // We must delete this FIRST, because we can't get the correct name for the affix file once we delete the main dictionary one.
            File.Delete(SpellingHelper.GetExceptionFileName(filePath));
            File.Delete(filePath);
            File.Delete(Path.ChangeExtension(filePath, ".aff"));
            SpellingHelper.EnsureDictionary(dictId);
            return(dictId);
        }