Ejemplo n.º 1
0
        /// <summary>
        /// 'internal static' so Reversal tests can use it
        /// </summary>
        internal static ILexEntryRef CreateVariantForm(LcmCache cache, IVariantComponentLexeme main, ILexEntry variantForm, string type = TestVariantName)
        {
            var owningList = cache.LangProject.LexDbOA.VariantEntryTypesOA;

            Assert.IsNotNull(owningList, "No VariantEntryTypes property on Lexicon object.");
            var varType = owningList.ReallyReallyAllPossibilities.LastOrDefault(poss => poss.Name.AnalysisDefaultWritingSystem.Text == type) as ILexEntryType;

            if (varType == null && type != null)             // if this type doesn't exist, create it
            {
                varType = cache.ServiceLocator.GetInstance <ILexEntryTypeFactory>().Create();
                owningList.PossibilitiesOS.Add(varType);
                varType.Name.set_String(cache.DefaultAnalWs, type);
            }
            var refOut = variantForm.MakeVariantOf(main, varType);

            // ILexEntry.MakeVariantOf sets a Type even if null is specified. But we want to test typeless variants, so clear them if null is specified.
            if (type == null)
            {
                refOut.VariantEntryTypesRS.Clear();
            }
            return(refOut);
        }