예제 #1
0
        private static void CheckMSA(string expectedText, int expectedWs, IMultiStringAccessor actual)
        {
            var actualText = TsStringUtils.NormalizeToNFC(actual.GetAlternativeOrBestTss(expectedWs, out var actualWs).Text);

            Assert.AreEqual(expectedText, actualText, $"WS Handle\n{expectedWs} requested\n{actualWs} returned");
            Assert.AreEqual(expectedWs, actualWs, expectedText);
        }
예제 #2
0
        private static ITsString GetTssGloss(IMultiStringAccessor gloss, CoreWritingSystemDefinition wsGloss)
        {
            int wsActual;
            var tssGloss = gloss.GetAlternativeOrBestTss(wsGloss.Handle, out wsActual);

            if (tssGloss == null || tssGloss.Length == 0)
            {
                tssGloss = gloss.NotFoundTss;
            }
            return(tssGloss);
        }
예제 #3
0
        /// <summary>
        /// </summary>
        /// <param name="variantEntryType"></param>
        /// <param name="gloss"></param>
        /// <param name="wsGloss"></param>
        /// <returns></returns>
        public static ITsString MakeGlossOptionWithInflVariantTypes(ILexEntryType variantEntryType, IMultiStringAccessor gloss, CoreWritingSystemDefinition wsGloss)
        {
            var inflVariantEntryType = variantEntryType as ILexEntryInflType;

            if (gloss == null || inflVariantEntryType == null)
            {
                return(null);
            }

            int       wsActual2;
            ITsString tssGloss = gloss.GetAlternativeOrBestTss(wsGloss.Handle, out wsActual2);

            if (tssGloss.Length == 0)
            {
                tssGloss = gloss.NotFoundTss;
            }

            var sb     = TsStringUtils.MakeIncStrBldr();
            var cache  = inflVariantEntryType.Cache;
            var wsUser = cache.ServiceLocator.WritingSystemManager.UserWritingSystem;

            ITsString tssGlossPrepend = AddTssGlossAffix(sb, inflVariantEntryType.GlossPrepend, wsGloss, wsUser);

            sb.AppendTsString(tssGloss);
            if (sb.Text.Length == 0)
            {
                return(null);                // TODO: add default value for gloss?
            }
            ITsString tssGlossAppend = AddTssGlossAffix(sb, inflVariantEntryType.GlossAppend, wsGloss, wsUser);

            if ((tssGlossPrepend == null || tssGlossPrepend.Length == 0) &&
                (tssGlossAppend == null || tssGlossAppend.Length == 0))
            {
                return(MakeGlossWithReverseAbbrs(gloss, wsGloss, new[] { variantEntryType }));
            }

            return(sb.GetString());
        }