public FastResume(BEncodedDictionary dict) { CheckContent(dict, VersionKey, 1); CheckContent(dict, InfoHashKey); CheckContent(dict, BitfieldKey); CheckContent(dict, BitfieldLengthKey); Infohash = new InfoHash(((BEncodedString) dict[InfoHashKey]).TextBytes); Bitfield = new BitField((int) ((BEncodedNumber) dict[BitfieldLengthKey]).Number); var data = ((BEncodedString) dict[BitfieldKey]).TextBytes; Bitfield.FromArray(data, 0, data.Length); }
public FastResume(BEncodedDictionary dict) { CheckContent(dict, VersionKey, (BEncodedNumber)1); CheckContent(dict, InfoHashKey); CheckContent(dict, BitfieldKey); CheckContent(dict, BitfieldLengthKey); infoHash = new InfoHash(((BEncodedString)dict[InfoHashKey]).TextBytes); bitfield = new BitField((int)((BEncodedNumber)dict[BitfieldLengthKey]).Number); byte[] data = ((BEncodedString)dict[BitfieldKey]).TextBytes; bitfield.FromArray(data, 0, data.Length); }
public FastResume(BEncodedDictionary dict) { CheckContent(dict, VersionKey, (BEncodedNumber)1); CheckContent(dict, InfoHashKey); CheckContent(dict, BitfieldKey); CheckContent(dict, BitfieldLengthKey); infoHash = new InfoHash(((BEncodedString)dict[InfoHashKey]).TextBytes); bitfield = new BitField((int)((BEncodedNumber)dict[BitfieldLengthKey]).Number); byte[] data = ((BEncodedString)dict[BitfieldKey]).TextBytes; bitfield.FromArray(data, 0, data.Length); if (dict.ContainsKey(PrioritiesKey)) { var list = (BEncodedList)dict[PrioritiesKey]; priorities = list.Select(v => (Priority)((BEncodedNumber)v).Number).ToArray(); } }
internal FastResume(BEncodedDictionary dict) { CheckVersion(dict); CheckContent(dict, InfoHashKey); CheckContent(dict, BitfieldKey); CheckContent(dict, BitfieldLengthKey); Infohash = new InfoHash(((BEncodedString)dict[InfoHashKey]).TextBytes); Bitfield = new BitField((int)((BEncodedNumber)dict[BitfieldLengthKey]).Number); byte[] data = ((BEncodedString)dict[BitfieldKey]).TextBytes; Bitfield.FromArray(data, 0); UnhashedPieces = new BitField(Bitfield.Length); // If we're loading up an older version of the FastResume data then we if (dict.ContainsKey(UnhashedPiecesKey)) { data = ((BEncodedString)dict[UnhashedPiecesKey]).TextBytes; UnhashedPieces.FromArray(data, 0); } }
public override void Decode(byte[] buffer, int offset, int length) { _bitField.FromArray(buffer, offset, length); }