private ICmPossibility CreateNewPossibility(List<string> rgsHier,
			CmPossibilityCreator factory,
			IFdoOwningSequence<ICmPossibility> possList,
			Dictionary<string, ICmPossibility> map,
			List<ICmPossibility> rgNew)
		{
			ICmPossibility possParent = null;
			ICmPossibility poss = null;
			int i;
			for (i = 0; i < rgsHier.Count; ++i)
			{
				if (!map.TryGetValue(rgsHier[i].ToLowerInvariant(), out poss))
					break;
				if (i > 0 && poss.Owner != possParent)
					break;
				possParent = poss;
			}
			if (i == rgsHier.Count)
			{
				// program bug -- shouldn't get here!
				Debug.Assert(i < rgsHier.Count);
				return null;
			}
			if (poss != null && i > 0 && poss.Owner != possParent)
			{
				// we can't create a duplicate name at a lower level in our current alogrithm!
				// Complain and do nothing...
				return null;
			}
			ICmPossibility itemParent = possParent as ICmAnthroItem;
			ICmPossibility item = null;
			for (; i < rgsHier.Count; ++i)
			{
				item = factory.Create();
				if (itemParent == null)
					possList.Add(item);
				else
					itemParent.SubPossibilitiesOS.Add(item);
				ITsString tss = m_cache.TsStrFactory.MakeString(rgsHier[i], m_cache.DefaultAnalWs);
				item.Name.AnalysisDefaultWritingSystem = tss;
				item.Abbreviation.AnalysisDefaultWritingSystem = tss;
				map.Add(rgsHier[i].ToLowerInvariant(), item);
				rgNew.Add(item);
				itemParent = item;
			}
			return item;
		}
Beispiel #2
0
		IPartOfSpeech CreatePartOfSpeech(IFdoOwningSequence<ICmPossibility> owningSeq,
			string sName, bool fCreateAffixTemplate)
		{
			IPartOfSpeech pos = Cache.ServiceLocator.GetInstance<IPartOfSpeechFactory>().Create();
			owningSeq.Add(pos);
			pos.Name.set_String(Cache.DefaultAnalWs, sName);
			if (fCreateAffixTemplate)
			{
				IMoInflAffixTemplate t = Cache.ServiceLocator.GetInstance<IMoInflAffixTemplateFactory>().Create();
				pos.AffixTemplatesOS.Add(t);
			}
			return pos;
		}