public void AddTitle(string TitleName, string TitleID) { if (!IsOpen || IsDisposed) { throw new Exception("TitleNameCache.AddTitle: The title name cache is not open."); } if (string.IsNullOrWhiteSpace(TitleName)) { throw new Exception("TitleNameCache.AddTitle: Invalid title name specified. It cannot be null, empty, or a white space character."); } if (TitleID.Length != 8 || TitleID.StartsWith("0x") || !XtraFunctions.IsValidBase16String(TitleID)) { throw new Exception("TitleNameCache.AddTitle: Invalid title ID specified. It must be 8 characters in length and in hexadecimal format without the '0x'."); } writer.BaseStream.Position = writer.BaseStream.Length; writer.WriteLine(TitleID); writer.WriteLine(TitleName); writer.Flush(); }
public string TitleIDToTitleName(string TitleID) { if (!IsOpen || IsDisposed) { throw new Exception("TitleNameCache.TitleIDToTitleName: The title name cache is not open."); } if (TitleID.Length != 8 || TitleID.StartsWith("0x") || !XtraFunctions.IsValidBase16String(TitleID)) { throw new Exception("TitleNameCache.TitleIDToTitleName: Invalid title ID specified. It must be 8 characters in length and in hexadecimal format without the '0x'."); } reader.BaseStream.Position = 0; string tid; string tn; while (!string.IsNullOrWhiteSpace(tid = reader.ReadLine()) && !string.IsNullOrWhiteSpace(tn = reader.ReadLine())) { if (String.CompareOrdinal(TitleID, tid) == 0) { return(tn); } } return("(NOT FOUND)"); }
public override string ToString() { return(XtraFunctions.ValueToHex(Address)); }
//NOTE: Sets stream position to the very end. public virtual byte[] ToArray() { return(XtraFunctions.ReadAllBytes(Stream)); }