Exemple #1
0
 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();
 }
Exemple #2
0
        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)");
        }
Exemple #3
0
 public override string ToString()
 {
     return(XtraFunctions.ValueToHex(Address));
 }
Exemple #4
0
 //NOTE: Sets stream position to the very end.
 public virtual byte[] ToArray()
 {
     return(XtraFunctions.ReadAllBytes(Stream));
 }