private bool TryGetKey(XmlDictionaryString s, out int key)
{
key = -1;
if (s.Dictionary == _dictionary)
{
key = s.Key * 2;
return true;
}
XmlDictionaryString t;
if (_dictionary != null && _dictionary.TryLookup(s, out t))
{
DiagnosticUtility.DebugAssert(t.Dictionary == _dictionary, "");
key = t.Key * 2;
return true;
}
if (_session == null)
return false;
int sessionKey;
if (!_session.TryLookup(s, out sessionKey))
{
if (!_session.TryAdd(s, out sessionKey))
return false;
}
key = sessionKey * 2 + 1;
return true;
}