예제 #1
0
        /// <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);
                }
            }
        }
예제 #2
0
        /// <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);
            }
        }
예제 #3
0
        /// <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();
                    }
            }
        }