/// <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)); }
public static T Decode <T>(RawReader reader) where T : BEncodedValue { return((T)BEncodedValue.Decode(reader)); }
/// <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)); }
public static T Decode <T>(byte[] buffer, int offset, int length, bool strictDecoding) where T : BEncodedValue { return((T)BEncodedValue.Decode(buffer, offset, length, strictDecoding)); }
public static T Clone <T> (T value) where T : BEncodedValue { Check.Value(value); return((T)BEncodedValue.Decode(value.Encode())); }
/// <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)); }
public void DecodeDictionary_MissingTrailingE() { string benString = "d1:a1:b"; Assert.Throws <BEncodingException> (() => BEncodedValue.Decode(Encoding.UTF8.GetBytes(benString))); }
public void DecodeString_TooShort() { string benString = "5:test"; Assert.Throws <BEncodingException> (() => BEncodedValue.Decode(Encoding.UTF8.GetBytes(benString))); }
public void DecodeString_NoColon() { string benString = "12"; Assert.Throws <BEncodingException> (() => BEncodedValue.Decode(Encoding.UTF8.GetBytes(benString))); }
public void DecodeNumber_InvalidDigit() { string benString = "i123$21e"; Assert.Throws <BEncodingException> (() => BEncodedValue.Decode(Encoding.UTF8.GetBytes(benString))); }
public void DecodeDictionary_OutOfOrder_Strict() { string benString = "d1:b1:b1:a1:ae"; Assert.Throws <BEncodingException> (() => BEncodedValue.Decode(Encoding.UTF8.GetBytes(benString), true)); }