2014-05-13 17:57:46 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using MonoTorrent.BEncoding;
|
|
|
|
|
|
|
|
namespace MonoTorrent
|
|
|
|
{
|
|
|
|
public class RawTrackerTier : IList<string>
|
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
public string this[int index]
|
|
|
|
{
|
|
|
|
get { return ((BEncodedString)Tier[index]).Text; }
|
|
|
|
set { Tier[index] = new BEncodedString(value); }
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
internal BEncodedList Tier
|
|
|
|
{
|
2014-05-13 17:57:46 +00:00
|
|
|
get; set;
|
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public RawTrackerTier()
|
|
|
|
: this(new BEncodedList())
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public RawTrackerTier(BEncodedList tier)
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
|
|
|
Tier = tier;
|
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public RawTrackerTier(IEnumerable<string> announces)
|
|
|
|
: this()
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
|
|
|
foreach (var v in announces)
|
2019-12-22 22:08:53 +00:00
|
|
|
Add(v);
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public int IndexOf(string item)
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
return Tier.IndexOf((BEncodedString)item);
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public void Insert(int index, string item)
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
Tier.Insert(index, (BEncodedString)item);
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public void RemoveAt(int index)
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
Tier.RemoveAt(index);
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public void Add(string item)
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
Tier.Add((BEncodedString)item);
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public void Clear()
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
Tier.Clear();
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public bool Contains(string item)
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
return Tier.Contains((BEncodedString)item);
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public void CopyTo(string[] array, int arrayIndex)
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
|
|
|
foreach (var s in this)
|
2019-12-22 22:08:53 +00:00
|
|
|
array[arrayIndex++] = s;
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public bool Remove(string item)
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
return Tier.Remove((BEncodedString)item);
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public int Count
|
|
|
|
{
|
2014-05-13 17:57:46 +00:00
|
|
|
get { return Tier.Count; }
|
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public bool IsReadOnly
|
|
|
|
{
|
2014-05-13 17:57:46 +00:00
|
|
|
get { return Tier.IsReadOnly; }
|
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
public IEnumerator<string> GetEnumerator()
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
|
|
|
foreach (BEncodedString v in Tier)
|
|
|
|
yield return v.Text;
|
|
|
|
}
|
|
|
|
|
2019-12-22 22:08:53 +00:00
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
2014-05-13 17:57:46 +00:00
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
return GetEnumerator();
|
2014-05-13 17:57:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|