System.Xml.XmlBinaryNodeWriter.TryGetKey C# (CSharp) Method

TryGetKey() private method

private TryGetKey ( XmlDictionaryString s, int &key ) : bool
s XmlDictionaryString
key int
return bool
        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;
        }