GetOrSet() public method

Gets the specified writing system if it exists, otherwise it creates a writing system using the specified identifier and sets it.
public GetOrSet ( string identifier, IWritingSystem &ws ) : bool
identifier string The identifier.
ws IWritingSystem The writing system.
return bool
        public void GetOrSetWorksRepeatedlyOnIdNeedingModification()
        {
            var            wsManager = new PalasoWritingSystemManager();
            IWritingSystem ws;

            Assert.That(wsManager.GetOrSet("x-kal", out ws), Is.False);
            Assert.That(ws.Id, Is.EqualTo("qaa-x-kal"));
            IWritingSystem ws2;

            Assert.That(wsManager.GetOrSet("x-kal", out ws2), Is.True);
            Assert.That(ws2, Is.EqualTo(ws));

            // By the way it should work the same for one where it does not have to modify the ID.
            Assert.That(wsManager.GetOrSet("fr", out ws), Is.False);
            Assert.That(wsManager.GetOrSet("fr", out ws), Is.True);
        }
		private PalasoWritingSystemManager GetWsf()
		{
			var wsf = new PalasoWritingSystemManager();
			IWritingSystem wsObj;
			wsf.GetOrSet("qaa-x-kal", out wsObj);
			EnsureQuoteAndHyphenWordForming(wsObj);
			return wsf;
		}
		public void Persistence()
		{
			var wsManager = new PalasoWritingSystemManager();
			IWritingSystem enWs;
			wsManager.GetOrSet("en", out enWs);
			int wsEng = enWs.Handle;

			IWritingSystem frWs;
			wsManager.GetOrSet("fr", out frWs);
			int wsFrn = frWs.Handle;

			IWritingSystem deWs;
			wsManager.GetOrSet("de", out deWs);
			int wsGer = deWs.Handle;

			InterlinLineChoices choices = new InterlinLineChoices(m_lp, wsFrn, wsEng);
			MakeStandardState(choices);
			string persist = choices.Persist(wsManager);
			choices = InterlinLineChoices.Restore(persist, wsManager, m_lp, wsFrn, wsEng);

			Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[4].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[5].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[6].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[7].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[8].Flid);

			// Check writing systems assigned by default.
			Assert.AreEqual(wsFrn, choices[0].WritingSystem);
			Assert.AreEqual(wsEng, choices[5].WritingSystem);
			Assert.AreEqual(wsFrn, choices[2].WritingSystem);

			choices = new EditableInterlinLineChoices(m_lp, 0, wsEng);
			MakeStandardState(choices);
			choices.Add(InterlinLineChoices.kflidLexGloss, wsGer);
			Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[4].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[5].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[6].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[7].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[8].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[9].Flid);

			Assert.AreEqual(wsGer, choices[4].WritingSystem);
		}
		public void GetOrSetWorksRepeatedlyOnIdNeedingModification()
		{
			var wsManager = new PalasoWritingSystemManager();
			IWritingSystem ws;
			Assert.That(wsManager.GetOrSet("x-kal", out ws), Is.False);
			Assert.That(ws.Id, Is.EqualTo("qaa-x-kal"));
			IWritingSystem ws2;
			Assert.That(wsManager.GetOrSet("x-kal", out ws2), Is.True);
			Assert.That(ws2, Is.EqualTo(ws));

			// By the way it should work the same for one where it does not have to modify the ID.
			Assert.That(wsManager.GetOrSet("fr", out ws), Is.False);
			Assert.That(wsManager.GetOrSet("fr", out ws), Is.True);
		}
		private static void RetrieveDefaultWritingSystemsFromLift(string liftPath, out IWritingSystem wsVern,
			out IWritingSystem wsAnalysis)
		{
			using (var liftReader = new StreamReader(liftPath, Encoding.UTF8))
			{
				string vernWsId, analysisWsId;
				using (var reader = XmlReader.Create(liftReader))
					RetrieveDefaultWritingSystemIdsFromLift(reader, out vernWsId, out analysisWsId);
				var wsManager = new PalasoWritingSystemManager(new GlobalFileWritingSystemStore());
				wsManager.GetOrSet(vernWsId, out wsVern);
				wsManager.GetOrSet(analysisWsId, out wsAnalysis);
			}
		}