/// <summary> /// Save /// </summary> public void Save() { lock (locker) { if (!Directory.Exists(Path.GetDirectoryName(this.FileName))) { Directory.CreateDirectory(Path.GetDirectoryName(this.FileName)); } // MPTickerのジョブリストが欠けていたら補完する var missingJobs = DefaultMPTickerTargetJobs.Where(x => !this.MPTicker.TargetJobs.Any(y => y.Job == x.Job)); if (missingJobs.Any()) { this.MPTicker.TargetJobs.AddRange(missingJobs); } using (var xw = XmlWriter.Create( this.FileName, this.XmlWriterSettings)) { this.Serializer.Serialize(xw, instance); } } }
/// <summary> /// Save /// </summary> public void Save() { lock (locker) { if (!Directory.Exists(Path.GetDirectoryName(this.FileName))) { Directory.CreateDirectory(Path.GetDirectoryName(this.FileName)); } // MPTickerのジョブリストが欠けていたら補完する var missingJobs = DefaultMPTickerTargetJobs.Where(x => !this.MPTicker.TargetJobs.Any(y => y.Job == x.Job)); if (missingJobs.Any()) { this.MPTicker.TargetJobs.AddRange(missingJobs); } var ns = new XmlSerializerNamespaces(); ns.Add(string.Empty, string.Empty); var buffer = new StringBuilder(); using (var sw = new StringWriter(buffer)) using (var xw = XmlWriter.Create(sw, this.XmlWriterSettings)) { this.Serializer.Serialize(xw, instance, ns); } buffer.Replace("utf-16", "utf-8"); File.WriteAllText( this.FileName, buffer.ToString() + Environment.NewLine, DefaultEncoding); } }
/// <summary> /// Save /// </summary> public void Save() { lock (locker) { if (!Directory.Exists(Path.GetDirectoryName(this.FileName))) { Directory.CreateDirectory(Path.GetDirectoryName(this.FileName)); } // MPTickerのジョブリストが欠けていたら補完する var missingJobs = DefaultMPTickerTargetJobs.Where(x => !this.MPTicker.TargetJobs.Any(y => y.Job == x.Job)); if (missingJobs.Any()) { this.MPTicker.TargetJobs.AddRange(missingJobs); } var ns = new XmlSerializerNamespaces(); ns.Add(string.Empty, string.Empty); using (var sw = new StreamWriter(this.FileName, false, DefaultEncoding)) using (var xw = XmlWriter.Create(sw, this.XmlWriterSettings)) { this.Serializer.Serialize(xw, instance, ns); xw.Close(); sw.Close(); } } }