public override ITsString get_StringProp(int hvo, int tag)
{
if ((tag == ktagAlternateValue) || (tag >= ktagAlternateValueMultiBase && tag < ktagAlternateValueMultiBaseLim))
{
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);
}