public static void Serialize(string solutionFilePath, SolutionFile obj, bool overwrite = true)
        {
            using (var fileStream = FileStreamHelper.NewWrite(solutionFilePath, overwrite))
                using (var textWriter = StreamWriterHelper.NewLeaveOpenAddBOM(fileStream))
                {
                    var solutionFileTextSerialializer = new SolutionFileTextSerializer();

                    solutionFileTextSerialializer.Serialize(textWriter, obj);
                }
        }
コード例 #2
0
        private static void EnsureBOMProduced()
        {
            var tempFilePath = @"C:\Temp\temp.txt";

            using (var fileStream = FileStreamHelper.NewWrite(tempFilePath))
                using (var writer = StreamWriterHelper.NewLeaveOpenAddBOM(fileStream))
                {
                    writer.WriteLine("Hello world! (BOM?)");
                }
        }
コード例 #3
0
        public void Serialize(Stream stream, T value)
        {
            StreamWriter GetStreamWriter()
            {
                var streamWriter = this.StreamSerializerOptions.Value.AddByteOrderMark
                    ? StreamWriterHelper.NewLeaveOpenAddBOM(stream)
                    : StreamWriterHelper.NewLeaveOpen(stream)
                ;

                return(streamWriter);
            }

            using (var textWriter = GetStreamWriter())
            {
                this.TextSerializer.Serialize(textWriter, value);
            }
        }