/// <summary> /// Saves the contents of the queue to the specified file /// </summary> /// <param name="filename">The name of the file to save the queue to. If this file exists, it is overwritten</param> /// <param name="schema">The current metadirectory services schema</param> public static void SaveQueue(string filename, Schema schema) { lock (CSEntryChangeQueue.queue) { CSEntryChangeSerializer.Serialize(CSEntryChangeQueue.queue, filename, schema); } }
/// <summary> /// Serializes the collection of CSEntryChange objects into the specified file /// </summary> /// <param name="csentries">The collection of CSEntryChanges to serialize</param> /// <param name="file">The name of the file to serialize the objects to. If this file exists, it will be overwritten</param> /// <param name="schema">The current metadirectory services schema. This is required to ensure that attributes are serialized as the correct data type</param> public static void Serialize(IEnumerable <CSEntryChange> csentries, string file, Schema schema) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.NewLineChars = Environment.NewLine; using (XmlWriter writer = XmlWriter.Create(file, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("cs-entry-changes"); foreach (CSEntryChange obj in csentries) { CSEntryChangeSerializer.Serialize(obj, writer, schema); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); } }