public void EmptyStringDoesNotThrow()
        {
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(3, 3);
            var             tssLabel      = m_tsf.EmptyString(WsDummy);

            Assert.IsFalse(rangeIntMatch.Matches(tssLabel));
        }
Esempio n. 2
0
 /// <summary>
 /// Override to handle ktagAlternateValue.
 /// </summary>
 public override ITsString get_StringProp(int hvo, int tag)
 {
     if (tag == ktagAlternateValue)
     {
         ITsString result;
         if (m_stringCache.TryGetValue(new HvoFlidKey(hvo, tag), out result))
         {
             return(result);
         }
         // Try to find a sensible WS from existing data, avoiding a crash if possible.
         // See FWR-3598.
         ITsString tss = null;
         foreach (var x in m_stringCache.Keys)
         {
             tss = m_stringCache[x];
             if (x.Flid == tag)
             {
                 break;
             }
         }
         if (tss == null)
         {
             foreach (var x in m_mlStringCache.Keys)
             {
                 ITsStrFactory tsf = TsStrFactoryClass.Create();
                 return(tsf.EmptyString(x.Ws));
             }
         }
         if (tss != null)
         {
             ITsStrFactory tsf = TsStrFactoryClass.Create();
             var           ws  = TsStringUtils.GetWsOfRun(tss, 0);
             return(tsf.EmptyString(ws));
         }
         // Enhance JohnT: might be desirable to return empty string rather than crashing,
         // but as things stand, we don't know what would be a sensible WS.
         throw new InvalidOperationException("trying to read a preview value not previously cached");
     }
     return(base.get_StringProp(hvo, tag));
 }
        /// <summary>
        /// Reload the vector in the root box, presumably after it's been modified by a chooser.
        /// </summary>
        public override void ReloadVector()
        {
            CheckDisposed();
            ITsStrFactory tsf = m_fdoCache.TsStrFactory;
            int           ws  = 0;

            if (m_rootObj != null && m_rootObj.IsValidObject)
            {
                ILgWritingSystemFactory wsf = m_fdoCache.WritingSystemFactory;
                int count = m_sda.get_VecSize(m_rootObj.Hvo, m_rootFlid);
                // This loop is mostly redundant now that the decorator will generate labels itself as needed.
                // It still serves the purpose of figuring out the WS that should be used for the 'fake' item where the user
                // is typing to select.
                for (int i = 0; i < count; ++i)
                {
                    int hvo = m_sda.get_VecItem(m_rootObj.Hvo, m_rootFlid, i);
                    Debug.Assert(hvo != 0);
                    ws = m_sda.GetLabelFor(hvo).get_WritingSystem(0);
                }

                if (ws == 0)
                {
                    var list = (ICmPossibilityList)m_rootObj.ReferenceTargetOwner(m_rootFlid);
                    ws = list.IsVernacular ? m_fdoCache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.Handle
                                                 : m_fdoCache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle;
                    if (list.PossibilitiesOS.Count > 0)
                    {
                        ObjectLabel label = ObjectLabel.CreateObjectLabel(m_fdoCache, list.PossibilitiesOS[0], m_displayNameProperty, m_displayWs);
                        ws = label.AsTss.get_WritingSystem(0);
                    }
                }
            }

            if (ws == 0)
            {
                ws = m_fdoCache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle;
            }
            m_sda.Strings[khvoFake] = tsf.EmptyString(ws);
            base.ReloadVector();
        }