public Event Deserialize(string s) { if (String.IsNullOrEmpty(s)) return null; try { string[] lines = s.Split('|'); if (lines[0].Length != 8) return null; Event newEvent = new Event(); string id = lines[0]; uint idNumber = Convert.ToUInt32(id, 16); newEvent.SetEventWord(idNumber); newEvent.pParameters = Allocate(newEvent.lParameters * 2); for (int i = 0; i < newEvent.lParameters; i++) { string[] pLines = lines[i + 1].Split('\\'); int word1 = int.Parse(pLines[0]); int word2 = UnHex(pLines[1]); newEvent.parameters[i].word1 = word1; newEvent.parameters[i].word2 = word2; SetWord(newEvent.parameters[i].word1, newEvent.pParameters + ToBlock(i)); if (newEvent.parameters[i].word1 != 2) SetWord(newEvent.parameters[i].word2, newEvent.pParameters + ToBlock(i) + B_WORD2); else SetPointer(newEvent.parameters[i].word2, newEvent.pParameters + ToBlock(i) + B_WORD2); } AddEvent(newEvent.GetEventWord(), newEvent.pParameters); return newEvent; } catch { return null; } }
// Read the event data at the specified offset and return as an Event. public Event ReadEventData(long offset) { Event eventData = new Event(); try { eventData.pThis = offset; eventData.SetEventWord(GetWord(eventData.pThis)); eventData.pParameters = GetWord(eventData.pThis + B_WORD2); for (int i = 0; i < eventData.lParameters; i++) { eventData.parameters[i].word1 = GetWord(eventData.pParameters + ToBlock(i)); eventData.parameters[i].word2 = GetWord(eventData.pParameters + ToBlock(i) + B_WORD2); } } catch { eventData = new Event(); } return eventData; }