예제 #1
0
        /// <summary>
        /// Transforms the given model using this instance's template.
        /// </summary>
        /// <param name="model">The model to transform.</param>
        /// <param name="writer">The <see cref="XmlWriter"/> to write the results of the transformation to.</param>
        public void Transform(MailModel model, XmlWriter writer)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model", "model cannot be null.");
            }

            if (writer == null)
            {
                throw new ArgumentNullException("writer", "writer cannot be null.");
            }

            XmlDocument stylesheet = new XmlDocument();
            stylesheet.Load(this.templateStream);

            XslCompiledTransform transform = new XslCompiledTransform();
            transform.Load(stylesheet);

            transform.Transform(model.ToXml(), writer);
        }