Exemplo n.º 1
0
            /// <summary>
            /// Constructs a dictionary
            /// </summary>
            /// <param name="istream">Stream to construct dictionary from</param>
            public Dictionary(IO.Stream istream)
            {
                if (istream.CanSeek)
                {
                    this.position = (int)istream.Position - 1;
                }
                int c;

                while ((c = istream.ReadByte()) != 'e')
                {
                    BEncode.String key     = new BEncode.String(istream, c);                 // keys are always strings
                    string         strkey  = key;
                    Element        element = BEncode.NextElement(istream);

                    if (!this.map.Contains(key))
                    {
                        this.map.Add(key, element);
                    }
                }

                if (istream.CanSeek)
                {
                    this.length = (int)istream.Position - this.position;
                }
            }
Exemplo n.º 2
0
            /// <summary>Constructs an integer from the bEncoded stream</summary>
            /// <param name="istream">Stream to construct integer from</param>
            public List(IO.Stream istream)
            {
                if (istream.CanSeek)
                {
                    this.position = (int)istream.Position - 1;
                }

                int c;

                while ((c = istream.ReadByte()) != 'e')
                {
                    BEncode.Element element = BEncode.NextElement(istream, c);
                    string          el      = element.ToString();
                    this.list.Add(element);
                }

                if (istream.CanSeek)
                {
                    this.length = (int)istream.Position - this.position;
                }
            }