BlueCollar.Dashboard.Index.Transform C# (CSharp) Method

Transform() public method

Transforms this instance into an HTML string using the embedded XSLT stylesheet.
public Transform ( ) : string
return string
        public string Transform()
        {
            XmlDocument stylesheet = new XmlDocument();
            MemoryStream outputStream = null;
            string html;

            using (Stream stream = GetType().Assembly.GetManifestResourceStream("BlueCollar.Dashboard.Static.index.xslt"))
            {
                stylesheet.Load(stream);
            }

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

            try
            {
                outputStream = new MemoryStream();
                transform.Transform(this.ToXml(), null, outputStream);
                outputStream.Position = 0;

                using (StreamReader reader = new StreamReader(outputStream))
                {
                    outputStream = null;
                    html = reader.ReadToEnd();
                }
            }
            finally
            {
                if (outputStream != null)
                {
                    outputStream.Dispose();
                }
            }

            return "<!DOCTYPE html>\r\n" + html;
        }

Usage Example

 public void UtilityIndexTransform()
 {
     Index index = new Index();
     string html = index.Transform();
     Assert.IsFalse(string.IsNullOrEmpty(html));
 }