コード例 #1
0
 public static bool SaveIfChanged(this XDocument document, string fileName)
 {
     using (var stream = new MemoryStream())
         using (var xw = new Monodroid.LinePreservedXmlWriter(new StreamWriter(stream))) {
             xw.WriteNode(document.CreateNavigator(), false);
             xw.Flush();
             return(MonoAndroidHelper.CopyIfStreamChanged(stream, fileName));
         }
 }
コード例 #2
0
 public static bool SaveIfChanged(this XDocument document, string fileName)
 {
     using (var sw = MemoryStreamPool.Shared.CreateStreamWriter(Encoding.Default))
         using (var xw = new Monodroid.LinePreservedXmlWriter(sw)) {
             xw.WriteNode(document.CreateNavigator(), false);
             xw.Flush();
             return(MonoAndroidHelper.CopyIfStreamChanged(sw.BaseStream, fileName));
         }
 }
コード例 #3
0
        public static bool SaveIfChanged(this XDocument document, string fileName)
        {
            var tempFile = System.IO.Path.GetTempFileName();

            try {
                using (var stream = File.OpenWrite(tempFile))
                    using (var xw = new Monodroid.LinePreservedXmlWriter(new StreamWriter(stream)))
                        xw.WriteNode(document.CreateNavigator(), false);
                return(MonoAndroidHelper.CopyIfChanged(tempFile, fileName));
            } finally {
                File.Delete(tempFile);
            }
        }