示例#1
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;
                }
            }
示例#2
0
 /// <summary>Adds a key-value pair to the dictionary</summary>
 /// <param name="key">Key</param>
 /// <param name="val">Value</param>
 public void Add(BEncode.String key, BEncode.Element val)
 {
     this.map.Add(key, val);
 }
示例#3
0
 /// <summary>Removes an element from the list</summary>
 /// <param name="obj">Element to remove</param>
 public void Remove(BEncode.Element element)
 {
     this.list.Remove(element);
 }
示例#4
0
 /// <summary>Inserts an element into the list at the specified index</summary>
 /// <param name="index">Index to insert element at</param>
 /// <param name="obj">Element to insert</param>
 public void Insert(int index, BEncode.Element element)
 {
     this.list.Insert(index, element);
 }
示例#5
0
 /// <summary>Finds the index at which the element resides</summary>
 /// <param name="obj">Element to check</param>
 /// <returns>Index of element, -1 if it does not exist</returns>
 public int IndexOf(BEncode.Element element)
 {
     return(this.list.IndexOf(element));
 }
示例#6
0
 /// <summary></summary>
 /// <param name="element">Object to check if it exists in the list</param>
 /// <returns>True if object is in the list, false otherwise</returns>
 public bool Contains(BEncode.Element element)
 {
     return(this.list.Contains(element));
 }
示例#7
0
 /// <summary></summary>
 /// <param name="element">Object to add to list</param>
 /// <returns>Index of object added</returns>
 public int Add(BEncode.Element element)
 {
     return(this.list.Add(element));
 }