SIL.FieldWorks.XWorks.DictionaryPublicationDecorator.get_MultiStringAlt C# (CSharp) Method

get_MultiStringAlt() public method

public get_MultiStringAlt ( int hvo, int tag, int ws ) : ITsString
hvo int
tag int
ws int
return ITsString
		public override ITsString get_MultiStringAlt(int hvo, int tag, int ws)
		{
			if (tag == m_mlHeadwordFlid)
			{
				int hn;
				if (m_homographNumbers.TryGetValue(hvo, out hn))
				{
					var entry = m_entryRepo.GetObject(hvo);
					return FDO.DomainServices.StringServices.HeadWordForWsAndHn(entry, ws, hn, "",
						HomographConfiguration.HeadwordVariant.Main);
				}
				// In case it's one we somehow don't know about, we'll let the base method try to get the real HN.
			}
			else if (tag == m_headwordRefFlid)
			{
				int hn;
				if (m_homographNumbers.TryGetValue(hvo, out hn))
				{
					var entry = m_entryRepo.GetObject(hvo);
					return FDO.DomainServices.StringServices.HeadWordForWsAndHn(entry, ws, hn, "",
						HomographConfiguration.HeadwordVariant.DictionaryCrossRef);
				}
				// In case it's one we somehow don't know about, we'll let the base method try to get the real HN.
			}
			else if (tag == m_headwordReversalFlid)
			{
				int hn;
				if (m_homographNumbers.TryGetValue(hvo, out hn))
				{
					var entry = m_entryRepo.GetObject(hvo);
					return FDO.DomainServices.StringServices.HeadWordForWsAndHn(entry, ws, hn, "",
						HomographConfiguration.HeadwordVariant.ReversalCrossRef);
				}
				// In case it's one we somehow don't know about, we'll let the base method try to get the real HN.
			}
			else if (tag == m_mlOwnerOutlineFlid)
			{
				// This adapts the logic of LexSense.OwnerOutlineNameForWs
				var sense = m_senseRepo.GetObject(hvo);
				return OwnerOutlineNameForWs(sense, ws, HomographConfiguration.HeadwordVariant.DictionaryCrossRef);
			}
			else if (tag == m_reversalNameFlid)
			{
				// This adapts the logic of LexSense.OwnerOutlineNameForWs
				var sense = m_senseRepo.GetObject(hvo);
				return OwnerOutlineNameForWs(sense, ws, HomographConfiguration.HeadwordVariant.ReversalCrossRef);
			}
			return base.get_MultiStringAlt(hvo, tag, ws);
		}

Usage Example

コード例 #1
0
        public void HomographAndHeadword()
        {
            Assert.That(m_blank2.HomographNumber, Is.EqualTo(2), "real HN should be set automatically");
            Assert.That(m_water2.HomographNumber, Is.EqualTo(2), "real HN should be set automatically");
            // These two are decremented because homograph 1 is not published
            Assert.That(m_decorator.get_IntProp(m_blank2.Hvo, LexEntryTags.kflidHomographNumber), Is.EqualTo(1));
            Assert.That(m_decorator.get_IntProp(m_blank3.Hvo, LexEntryTags.kflidHomographNumber), Is.EqualTo(2));
            // This one is reduced because with the only other homograph not published, it should not appear to be
            // a homograph at all.
            Assert.That(m_decorator.get_IntProp(m_water.Hvo, LexEntryTags.kflidHomographNumber), Is.EqualTo(0));
            int headwordFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "HeadWord", false);

            Assert.That(m_decorator.get_StringProp(m_blank2.Hvo, headwordFlid).Text, Is.EqualTo("blank1"));
            Assert.That(m_decorator.get_StringProp(m_water.Hvo, headwordFlid).Text, Is.EqualTo("water"));
            Assert.That(m_decorator.get_StringProp(m_waterPrefix.Hvo, headwordFlid).Text, Is.EqualTo("water-"));

            int mlHeadwordFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "MLHeadWord", false);

            Assert.That(m_decorator.get_MultiStringAlt(m_blank2.Hvo, mlHeadwordFlid, Cache.DefaultVernWs).Text, Is.EqualTo("blank1"));
            Assert.That(m_decorator.get_MultiStringAlt(m_water.Hvo, mlHeadwordFlid, Cache.DefaultVernWs).Text, Is.EqualTo("water"));
            Assert.That(m_decorator.get_MultiStringAlt(m_waterPrefix.Hvo, mlHeadwordFlid, Cache.DefaultVernWs).Text, Is.EqualTo("water-"));
        }