Commit 78b7976d authored by Brickner_cp's avatar Brickner_cp

DNS.

Code coverage 92.72%
parent 57590253
...@@ -5,7 +5,7 @@ using System.Linq; ...@@ -5,7 +5,7 @@ using System.Linq;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
public class ListSegment<T> : IList<T> internal class ListSegment<T> : IEnumerable<T>
{ {
public ListSegment(IList<T> data, int startIndex, int count) public ListSegment(IList<T> data, int startIndex, int count)
{ {
...@@ -30,68 +30,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -30,68 +30,8 @@ namespace PcapDotNet.Packets.Dns
return GetEnumerator(); return GetEnumerator();
} }
public void Add(T item)
{
throw new NotSupportedException("ListSegment<T> is read-only");
}
public void Clear()
{
throw new NotSupportedException("ListSegment<T> is read-only");
}
public bool Contains(T item)
{
return Enumerable.Contains(this, item);
}
public void CopyTo(T[] array, int arrayIndex)
{
foreach (T value in this)
array[arrayIndex++] = value;
}
public bool Remove(T item)
{
throw new NotSupportedException("ListSegment<T> is read-only");
}
public int Count { get; private set; } public int Count { get; private set; }
public bool IsReadOnly
{
get { return true; }
}
public int IndexOf(T item)
{
if (ReferenceEquals(item, null))
{
for (int i = 0; i != Count; ++i)
{
if (ReferenceEquals(this[i], null))
return i;
}
return -1;
}
for (int i = 0; i != Count; ++i)
{
if (item.Equals(this[i]))
return i;
}
return -1;
}
public void Insert(int index, T item)
{
throw new NotSupportedException("ListSegment<T> is read-only");
}
public void RemoveAt(int index)
{
throw new NotSupportedException("ListSegment<T> is read-only");
}
public T this[int index] public T this[int index]
{ {
...@@ -99,16 +39,6 @@ namespace PcapDotNet.Packets.Dns ...@@ -99,16 +39,6 @@ namespace PcapDotNet.Packets.Dns
set { throw new NotSupportedException("ListSegment<T> is read-only"); } set { throw new NotSupportedException("ListSegment<T> is read-only"); }
} }
public ListSegment<T> SubSegment(int startIndex, int count)
{
return new ListSegment<T>(_data, _startIndex + startIndex, count);
}
public ListSegment<T> SubSegment(int startIndex)
{
return SubSegment(startIndex, Count - startIndex);
}
private readonly IList<T> _data; private readonly IList<T> _data;
private readonly int _startIndex; private readonly int _startIndex;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment