public void Post(DomainActionBase action) { if (this.isEnabled == false) { return; } var message = string.Empty; this.current = action; action.ID = this.id++; var s = XmlSerializerUtility.GetSerializer(action.GetType()); var ns = new XmlSerializerNamespaces(); ns.Add(string.Empty, string.Empty); ns.Add("fn", action.GetType().AssemblyQualifiedName); using (var sw = new Utf8StringWriter()) using (var writer = XmlWriter.Create(sw, writerSettings)) { DataContractSerializerUtility.Write(writer, action); writer.Close(); message = sw.ToString(); } this.postedWriter.WriteLine(message); }
public void Complete() { if (this.isEnabled == false) { return; } var message = string.Empty; using (var sw = new Utf8StringWriter()) using (var writer = XmlWriter.Create(sw, writerSettings)) { writer.WriteStartElement("Action"); { writer.WriteAttributeString("ID", this.current.ID.ToString()); writer.WriteAttributeString("DateTime", DateTime.Now.ToString("o")); } writer.WriteEndElement(); writer.Close(); message = sw.ToString(); } this.completedWriter.WriteLine(message); this.current = null; }
private void CollectPostedActions() { var postedPath = Path.Combine(this.workingPath, DomainLogger.PostedFileName); using (var reader = XmlReader.Create(postedPath, readerSettings)) { reader.Read(); while (reader.EOF != true) { DomainActionBase actionObject = null; if (reader.Name == typeof(NewRowAction).Name) { actionObject = DataContractSerializerUtility.Read <NewRowAction>(reader); } else if (reader.Name == typeof(RemoveRowAction).Name) { actionObject = DataContractSerializerUtility.Read <RemoveRowAction>(reader); } else if (reader.Name == typeof(SetRowAction).Name) { actionObject = DataContractSerializerUtility.Read <SetRowAction>(reader); } else if (reader.Name == typeof(SetPropertyAction).Name) { actionObject = DataContractSerializerUtility.Read <SetPropertyAction>(reader); } else if (reader.Name == typeof(JoinAction).Name) { actionObject = DataContractSerializerUtility.Read <JoinAction>(reader); } else if (reader.Name == typeof(DisjoinAction).Name) { actionObject = DataContractSerializerUtility.Read <DisjoinAction>(reader); } else if (reader.Name == typeof(KickAction).Name) { actionObject = DataContractSerializerUtility.Read <KickAction>(reader); } else if (reader.Name == typeof(SetOwnerAction).Name) { actionObject = DataContractSerializerUtility.Read <SetOwnerAction>(reader); } else { throw new NotImplementedException(); } this.lastID = actionObject.ID; if (this.completedActions.Contains(actionObject.ID) == false) { continue; } this.postedActions.Add(actionObject); } } }