Ejemplo n.º 1
0
        public void Render()
        {
            Utility.EnsureDirectory(_filename);
            var sw = new StreamWriter(_filename, false);

            sw.WriteLine(_header.Length > 0 ? HtmlLib.HTMLOpenPlus(_header) : HtmlLib.HTMLOpen());
            sw.WriteLine(HtmlLib.HeadOpen());
            sw.WriteLine("\t" + HtmlLib.HTMLTitle(_title));
            if (_cssFile != null)
            {
                if (_cssFile.Length > 0)
                {
                    sw.WriteLine("\t" + HtmlLib.CssLink(_cssFile));
                }
            }
            if (_script1 != null)
            {
                if (_script1.Length > 0)
                {
                    sw.WriteLine("\t" + HtmlLib.VBScriptFile(_script1));
                }
            }
            if (_script2 != null)
            {
                if (_script2.Length > 0)
                {
                    sw.WriteLine("\t" + HtmlLib.JSScriptFile(_script2));
                }
            }
            if (TopScripts != null)
            {
                RenderTopScripts(sw);
            }

            if (StyleList.Count > 0)
            {
                var styleEnumerator = StyleList.GetEnumerator();
                sw.WriteLine("\t" + HtmlLib.StyleOpen());
                while (styleEnumerator.MoveNext())
                {
                    sw.WriteLine("\t" + styleEnumerator.Current);
                }
                sw.WriteLine("\t" + HtmlLib.StyleClose());
            }

            sw.WriteLine(HtmlLib.HeadClose());
            sw.WriteLine(HtmlLib.BodyOpen());

            sw.WriteLine(HtmlLib.DivOpen("id=\"container\""));

            //  Add the body parts
            var myEnumerator = _bodyList.GetEnumerator();

            while (myEnumerator.MoveNext())
            {
                sw.WriteLine(myEnumerator.Current);
            }

            sw.WriteLine(HtmlLib.DivClose());

            if (Scripts != null)
            {
                WriteScripts(sw);
            }
            sw.WriteLine(HtmlLib.BodyClose());
            sw.WriteLine(HtmlLib.HtmlClose());
            sw.Close();

            if (AnnounceIt)
            {
                Announce(string.Format("   {0} has been rendered", _filename));
            }
        }