コード例 #1
0
        public static BEncodedValue Decode(byte[] buffer, int offset, int length, bool strictDecoding)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            if (offset < 0 || length < 0)
            {
                throw new IndexOutOfRangeException("Neither offset or length can be less than zero");
            }

            if (offset > buffer.Length - length)
            {
                throw new ArgumentOutOfRangeException("length");
            }

            using (RawReader reader = new RawReader(new MemoryStream(buffer, offset, length), strictDecoding))
                return(BEncodedValue.Decode(reader));
        }
コード例 #2
0
 public static T Clone <T> (T value)
     where T : BEncodedValue
 {
     Check.Value(value);
     return((T)BEncodedValue.Decode(value.Encode()));
 }
コード例 #3
0
 public static T Decode <T>(RawReader reader) where T : BEncodedValue
 {
     return((T)BEncodedValue.Decode(reader));
 }
コード例 #4
0
 /// <summary>
 /// Decode BEncoded data in the given stream
 /// </summary>
 /// <param name="stream">The stream containing the BEncoded data</param>
 /// <returns>BEncodedValue containing the data that was in the stream</returns>
 public static T Decode <T>(Stream stream) where T : BEncodedValue
 {
     return((T)BEncodedValue.Decode(stream));
 }
コード例 #5
0
 public static T Decode <T>(byte[] buffer, int offset, int length, bool strictDecoding) where T : BEncodedValue
 {
     return((T)BEncodedValue.Decode(buffer, offset, length, strictDecoding));
 }
コード例 #6
0
 /// <summary>
 /// Decode BEncoded data in the given byte array
 /// </summary>
 /// <param name="buffer">The byte array containing the BEncoded data</param>
 /// <param name="offset">The offset at which the data starts at</param>
 /// <param name="length">The number of bytes to be decoded</param>
 /// <returns>BEncodedValue containing the data that was in the byte[]</returns>
 public static T Decode <T>(byte[] buffer, int offset, int length) where T : BEncodedValue
 {
     return(BEncodedValue.Decode <T>(buffer, offset, length, true));
 }
コード例 #7
0
 /// <summary>
 /// Interface for all BEncoded values
 /// </summary>
 /// <param name="data">The byte array containing the BEncoded data</param>
 /// <returns></returns>
 public static T Decode <T>(byte[] data) where T : BEncodedValue
 {
     return((T)BEncodedValue.Decode(data));
 }