public void WriteType(Stream stream, NustacheGeneratedType generatedType, string suffix)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (generatedType == null)
            {
                throw new ArgumentNullException(nameof(generatedType));
            }

            if (generatedType.Type == null)
            {
                throw new ArgumentOutOfRangeException(nameof(generatedType));
            }

            var template = File.ReadAllText(generatedType.Template);
            var rendered = this.stubble.Render(template, generatedType.Type);

            using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8, 1024, leaveOpen: true))
            {
                writer.Write(rendered);
            }
        }
Esempio n. 2
0
        public void WriteType(Stream stream, NustacheGeneratedType generatedType, string suffix)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (generatedType == null)
            {
                throw new ArgumentNullException(nameof(generatedType));
            }

            if (generatedType.Type == null)
            {
                throw new ArgumentOutOfRangeException(nameof(generatedType));
            }

            using (var reader = new StreamReader(generatedType.Template))
                using (StreamWriter writer = new StreamWriter(stream, Encoding.Default, bufferSize: 4096, leaveOpen: true))
                {
                    Render.Template(reader, generatedType.Type, writer);
                }
        }