using System;

namespace SharpQuake
{
	internal class ByteArraySegment
	{
		public byte[] Data
		{
			get
			{
				return this._Segment.Array;
			}
		}

		public int StartIndex
		{
			get
			{
				return this._Segment.Offset;
			}
		}

		public int Length
		{
			get
			{
				return this._Segment.Count;
			}
		}

		public ByteArraySegment(byte[] array) : this(array, 0, -1)
		{
		}

		public ByteArraySegment(byte[] array, int startIndex) : this(array, startIndex, -1)
		{
		}

		public ByteArraySegment(byte[] array, int startIndex, int length)
		{
			if (array == null)
			{
				throw new ArgumentNullException("array");
			}
			if (length == -1)
			{
				length = array.Length - startIndex;
			}
			if (length <= 0)
			{
				throw new ArgumentException("Invalid length!");
			}
			this._Segment = new ArraySegment<byte>(array, startIndex, length);
		}

		private ArraySegment<byte> _Segment;
	}
}
