internal static IBencodingType Decode(BinaryReader inputStream) { char next = (char)inputStream.PeekChar(); switch (next) { case 'i': // Integer return(BInt.Decode(inputStream)); case 'l': // List return(BList.Decode(inputStream)); case 'd': // List return(BDict.Decode(inputStream)); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': // String return(BString.Decode(inputStream)); } return(null); }
public bool Equals(BInt other) { if (other == null) { return(false); } return(Equals(other.Value)); }
public int CompareTo(BInt other) { if (other == null) { throw new ArgumentNullException("other"); } if (Value < other.Value) { return(-1); } if (Value > other.Value) { return(1); } return(0); }
/// <summary> /// Decode the next token as a int. /// Assumes the next token is a int. /// </summary> /// <param name="inputStream"></param> /// <returns>Decoded int</returns> public static BInt Decode(BinaryReader inputStream) { // Get past 'i' inputStream.Read(); // Read numbers till an 'e' string number = ""; char ch; while ((ch = inputStream.ReadChar()) != 'e') { number += ch; } BInt res = new BInt { Value = long.Parse(number) }; return(res); }
public override bool Equals(object obj) { BInt other = obj as BInt; return(Equals(other)); }