Inheritance: INotifyPropertyChanged
Esempio n. 1
0
        public static ChatLogEntry Process(byte[] raw)
        {
            var chatLogEntry = new ChatLogEntry();
            try
            {
                chatLogEntry.Bytes = raw;
                chatLogEntry.TimeStamp = UnixTimeStampToDateTime(int.Parse(ByteArrayToString(raw.Take(4)
                                                                                                .Reverse()
                                                                                                .ToArray()), NumberStyles.HexNumber));
                chatLogEntry.Code = ByteArrayToString(raw.Skip(4)
                                                         .Take(2)
                                                         .Reverse()
                                                         .ToArray());
                chatLogEntry.Raw = Encoding.UTF8.GetString(raw.ToArray());
                var cleanable = raw.Skip(8)
                                   .ToArray();
                var cleaned = new ChatCleaner(cleanable).Result;
                var cut = (cleaned.Substring(1, 1) == ":") ? 2 : 1;
                chatLogEntry.Line = XmlHelper.SanitizeXmlString(cleaned.Substring(cut));
                chatLogEntry.Line = new ChatCleaner(chatLogEntry.Line).Result;
                chatLogEntry.JP = Encoding.UTF8.GetBytes(chatLogEntry.Line)
                                          .Any(b => b > 128);

                chatLogEntry.Combined = $"{chatLogEntry.Code}:{chatLogEntry.Line}";
            }
            catch (Exception)
            {
                chatLogEntry.Bytes = new byte[0];
                chatLogEntry.Raw = "";
                chatLogEntry.Line = "";
                chatLogEntry.Code = "";
                chatLogEntry.Combined = "";
            }
            return chatLogEntry;
        }
Esempio n. 2
0
        public static ChatLogEntry Process(byte[] raw)
        {
            var chatLogEntry = new ChatLogEntry();

            try
            {
                chatLogEntry.Bytes     = raw;
                chatLogEntry.TimeStamp = UnixTimeStampToDateTime(int.Parse(ByteArrayToString(raw.Take(4)
                                                                                             .Reverse()
                                                                                             .ToArray()), NumberStyles.HexNumber));
                chatLogEntry.Code = ByteArrayToString(raw.Skip(4)
                                                      .Take(2)
                                                      .Reverse()
                                                      .ToArray());
                chatLogEntry.Raw = Encoding.UTF8.GetString(raw.ToArray());
                var cleanable = raw.Skip(8)
                                .ToArray();
                var cleaned = new ChatCleaner(cleanable).Result;
                var cut     = cleaned.Substring(1, 1) == ":" ? 2 : 1;
                chatLogEntry.Line = XmlHelper.SanitizeXmlString(cleaned.Substring(cut));
                chatLogEntry.Line = new ChatCleaner(chatLogEntry.Line).Result;
                chatLogEntry.JP   = IsJapanese(chatLogEntry.Line);

                chatLogEntry.Combined = $"{chatLogEntry.Code}:{chatLogEntry.Line}";
            }
            catch (Exception)
            {
                chatLogEntry.Bytes    = new byte[0];
                chatLogEntry.Raw      = string.Empty;
                chatLogEntry.Line     = string.Empty;
                chatLogEntry.Code     = string.Empty;
                chatLogEntry.Combined = string.Empty;
            }
            return(chatLogEntry);
        }