private static void WriteLogEvent(XmlWriter writer, WritingSystemLogEvent logEvent) { writer.WriteStartElement(logEvent.Type); writer.WriteAttributeString("Producer", logEvent.Producer); writer.WriteAttributeString("ProducerVersion", logEvent.ProducerVersion); writer.WriteAttributeString("TimeStamp", logEvent.DateTime.ToISO8601DateAndUTCTimeString()); switch (logEvent.Type) { case "Change": var changeEvent = (WritingSystemLogChangeEvent)logEvent; writer.WriteElementString("From", changeEvent.From); writer.WriteElementString("To", changeEvent.To); break; case "Merge": var conflateEvent = (WritingSystemLogConflateEvent)logEvent; writer.WriteElementString("From", conflateEvent.From); writer.WriteElementString("To", conflateEvent.To); break; case "Delete": var deleteEvent = (WritingSystemLogDeleteEvent)logEvent; writer.WriteElementString("Id", deleteEvent.Id); break; case "Add": var addEvent = (WritingSystemLogAddEvent)logEvent; writer.WriteElementString("Id", addEvent.Id); break; } writer.WriteEndElement(); }
private void WriteToLog(WritingSystemLogEvent logEvent) { //_logEvents.Clear(); _logEvents.Add(logEvent); if (File.Exists(_dataMapper.FilePath)) { _dataMapper.AppendEvent(logEvent); } else { _dataMapper.Write(this); } //_dataMapper.Read(this); }
public void AppendEvent(WritingSystemLogEvent logEvent) { using (StreamReader streamReader = File.OpenText(FilePath)) { using (XmlReader reader = XmlReader.Create(streamReader, _xmlReadSettings)) { using (var streamWriter = new StreamWriter(_tempWriteFilePath)) { using (var writer = XmlWriter.Create(streamWriter, CanonicalXmlSettings.CreateXmlWriterSettings())) { CopyUntilEndOfChanges(reader, writer); WriteLogEvent(writer, logEvent); writer.WriteEndElement(); // Changes writer.WriteEndElement(); // WritingSystemChangeLog writer.Close(); } } } } File.Delete(FilePath); File.Move(_tempWriteFilePath, FilePath); }
public void AppendEvent(WritingSystemLogEvent logEvent) {}
// only intended for use by the datamapper internal void AddEvent(WritingSystemLogEvent logEvent) { _logEvents.Add(logEvent); }
public void AppendEvent(WritingSystemLogEvent logEvent) { }