CSL.BEncoding.decode_dict C# (CSharp) Method

decode_dict() public static method

public static decode_dict ( byte x, int &f ) : ListDictionary
x byte
f int
return System.Collections.Specialized.ListDictionary
        public static ListDictionary decode_dict(byte[] x, ref int f)
        {
            ListDictionary r = new ListDictionary();
            string lastkey = null;

            while (x[f] != 'e')
            {
                string k = decode_string(x, ref f);
                if (lastkey != null && lastkey.CompareTo(k) >= 0)
                    //throw new BitTorrentException("Dictionary contains duplicate key or is incorrectly sorted");
                lastkey = k;

                object v;
                // Hack - certain keys are read as byte[]
                if ((k != "pieces") && (k != "peer id"))
                {
                    v = bdecode_rec(x, ref f);
                }
                else
                {
                    v = decode_bytes(x, ref f);
                }
                r.Add(k, v);
            }
            f += 1;
            return r;
        }