Beispiel #1
0
        private void WriteGeneratedFile(Builder builder, string path, IEnumerable <IDictionary <string, object> > database, List <string> generatedFiles, List <string> skipFiles)
        {
            var file = new FileInfo(Path.Combine(path, FileName));

            using (var stream = new MemoryStream())
                using (var writer = new StreamWriter(stream, new UTF8Encoding(false)))
                    using (var serializer = new Util.JsonSerializer(writer)
                    {
                        IsOutputFormatted = true
                    })
                    {
                        serializer.Serialize(database);
                        serializer.Flush();

                        if (builder.Context.WriteGeneratedFile(null, file, stream))
                        {
                            generatedFiles.Add(Path.Combine(file.DirectoryName, file.Name));
                        }
                        else
                        {
                            skipFiles.Add(Path.Combine(file.DirectoryName, file.Name));
                        }
                    }
        }
        public void Dispose()
        {
            _serializer.Dispose();

            Assert.Throws <ObjectDisposedException>(delegate
                                                    { _writer.Write(string.Empty); });
            Assert.Throws <ObjectDisposedException>(delegate
                                                    { _serializer.Serialize(string.Empty); });
        }