Exists() public method

Determines if a writing system exists with the specified handle.
public Exists ( int handle ) : bool
handle int The handle.
return bool
        public void SerializeDeserialize()
        {
            string storePath = PrepareTempStore("Store");

            // serialize
            var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
            var ws        = wsManager.Set("en-US");

            ws.SpellCheckingId = "en-US";
            ws.MatchedPairs    = "matched pairs";
            ws.LCID            = 0x409;
            ws.ValidChars      = "valid characters";
            ws.LegacyMapping   = "legacy mapping";
            wsManager.Save();

            // deserialize
            wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
            Assert.IsTrue(wsManager.Exists("en-US"));
            ws = wsManager.Get("en-US");
            Assert.AreEqual("Eng", ws.Abbreviation);
            Assert.AreEqual("English", ws.LanguageSubtag.Name);
            Assert.AreEqual("en-US", ws.SpellCheckingId);
            Assert.AreEqual("United States", ws.RegionSubtag.Name);
            Assert.AreEqual("matched pairs", ws.MatchedPairs);
            Assert.AreEqual(0x409, ws.LCID);
            Assert.AreEqual("valid characters", ws.ValidChars);
            Assert.AreEqual("legacy mapping", ws.LegacyMapping);
            Assert.AreEqual("eng", ws.ISO3);
            wsManager.Save();
        }
Esempio n. 2
0
        public void FieldWorksExtensionsAreNotDuplicatedOnRoundTrip()
        {
            var storePath = PrepareTempStore("Store");

            // serialize
            var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
            var ws        = wsManager.Set("en-US");

            ws.SpellCheckingId = "en-US";
            ws.MatchedPairs    = "matched pairs";
            ((ILegacyWritingSystemDefinition)ws).WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture);
            ws.ValidChars    = "valid characters";
            ws.LegacyMapping = "legacy mapping";
            wsManager.Save();

            // deserialize
            wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
            Assert.IsTrue(wsManager.Exists("en-US"), "broken before SUT.");
            ws = wsManager.Get("en-US");
            Assert.AreEqual("valid characters", ws.ValidChars, "broken before SUT");
            //change the valid chars data and save back out, this was duplicating in LT-15048
            ws.ValidChars = "more valid characters";
            wsManager.Save();

            var xmlDoc = new XmlDocument();

            xmlDoc.Load(Path.Combine(storePath, "en-US.ldml"));
            Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars']").Count, "Special fw elements were duplicated");
            Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars' and @value='more valid characters']").Count, "special fw changes not saved");
        }
        public void get_Engine()
        {
            var              wsManager = new PalasoWritingSystemManager();
            IWritingSystem   enWs      = wsManager.Set("en-US");
            ILgWritingSystem enLgWs    = wsManager.get_Engine("en-US");

            Assert.AreSame(enWs, enLgWs);

            Assert.IsFalse(wsManager.Exists("en-Latn-US"));
            // this should create a new writing system, since it doesn't exist
            ILgWritingSystem enUsLgWs = wsManager.get_Engine("en-Latn-US");

            Assert.IsTrue(wsManager.Exists("en-Latn-US"));
            Assert.IsTrue(wsManager.Exists(enUsLgWs.Handle));
            IWritingSystem enUsWs = wsManager.Get("en-Latn-US");

            Assert.AreSame(enUsWs, enUsLgWs);
            wsManager.Save();
        }
		public void SerializeDeserialize()
		{
			string storePath = PrepareTempStore("Store");

			// serialize
			var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
			var ws = wsManager.Set("en-US");
			ws.SpellCheckingId = "en-US";
			ws.MatchedPairs = "matched pairs";
			((ILegacyWritingSystemDefinition)ws).WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture);
			ws.ValidChars = "valid characters";
			ws.LegacyMapping = "legacy mapping";
			wsManager.Save();

			// deserialize
			wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
			Assert.IsTrue(wsManager.Exists("en-US"));
			ws = wsManager.Get("en-US");
			Assert.AreEqual("Eng", ws.Abbreviation);
			Assert.AreEqual("English", ws.LanguageSubtag.Name);
			Assert.AreEqual("en-US", ws.SpellCheckingId);
			Assert.AreEqual("United States", ws.RegionSubtag.Name);
			Assert.AreEqual("matched pairs", ws.MatchedPairs);
			Assert.AreEqual(0x409.ToString(CultureInfo.InvariantCulture), ((ILegacyWritingSystemDefinition)ws).WindowsLcid);
			Assert.AreEqual("valid characters", ws.ValidChars);
			Assert.AreEqual("legacy mapping", ws.LegacyMapping);
			Assert.AreEqual("eng", ws.ISO3);
			wsManager.Save();
		}
		public void get_Engine()
		{
			var wsManager = new PalasoWritingSystemManager();
			IWritingSystem enWs = wsManager.Set("en-US");
			ILgWritingSystem enLgWs = wsManager.get_Engine("en-US");
			Assert.AreSame(enWs, enLgWs);

			Assert.IsFalse(wsManager.Exists("en-Latn-US"));
			// this should create a new writing system, since it doesn't exist
			ILgWritingSystem enUsLgWs = wsManager.get_Engine("en-Latn-US");
			Assert.IsTrue(wsManager.Exists("en-Latn-US"));
			Assert.IsTrue(wsManager.Exists(enUsLgWs.Handle));
			IWritingSystem enUsWs = wsManager.Get("en-Latn-US");
			Assert.AreSame(enUsWs, enUsLgWs);
			wsManager.Save();
		}
		public void FieldWorksExtensionsAreNotDuplicatedOnRoundTrip()
		{
			var storePath = PrepareTempStore("Store");

			// serialize
			var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
			var ws = wsManager.Set("en-US");
			ws.SpellCheckingId = "en-US";
			ws.MatchedPairs = "matched pairs";
			((ILegacyWritingSystemDefinition)ws).WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture);
			ws.ValidChars = "valid characters";
			ws.LegacyMapping = "legacy mapping";
			wsManager.Save();

			// deserialize
			wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
			Assert.IsTrue(wsManager.Exists("en-US"), "broken before SUT.");
			ws = wsManager.Get("en-US");
			Assert.AreEqual("valid characters", ws.ValidChars, "broken before SUT");
			//change the valid chars data and save back out, this was duplicating in LT-15048
			ws.ValidChars = "more valid characters";
			wsManager.Save();

			var xmlDoc = new XmlDocument();
			xmlDoc.Load(Path.Combine(storePath, "en-US.ldml"));
			Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars']").Count, "Special fw elements were duplicated");
			Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars' and @value='more valid characters']").Count, "special fw changes not saved");
		}