示例#1
0
        void WriteDictionaryIndex(XmlDictionaryString ds)
        {
            XmlDictionaryString ds2;
            bool isSession = false;
            int  idx       = ds.Key;

            if (ds.Dictionary != dict_ext)
            {
                isSession = true;
                if (dict_int.TryLookup(ds.Value, out ds2))
                {
                    ds = ds2;
                }
                if (!session.TryLookup(ds, out idx))
                {
                    session.TryAdd(dict_int.Add(ds.Value), out idx);
                }
            }
            if (idx >= 0x80)
            {
                writer.Write((byte)(0x80 + ((idx % 0x80) << 1) + (isSession ? 1 : 0)));
                writer.Write((byte)((byte)(idx / 0x80) << 1));
            }
            else
            {
                writer.Write((byte)(((idx % 0x80) << 1) + (isSession ? 1 : 0)));
            }
        }