Example #1
0
        public void Refresh(Object obj)
        {
#if (false)
            Template template = Template.Parse(this.template);
            String   DOM      = template.Render(Hash.FromAnonymousObject(obj));
#endif
#if (false)
            if (obj == null)
            {
                return;
            }
#endif
            //try
            {
                String      DOM    = Preprocessor.Preprocess(this.template, obj);
                XmlDocument xmlDoc = new XmlDocument();
                if (DOM == "NONCHANGE" || String.IsNullOrEmpty(DOM))
                {
                    return;
                }
                try
                {
                    xmlDoc.LoadXml(DOM);
                }
                catch (Exception e)
                {
                    using (StreamReader sr = new StreamReader("views/error.xml"))
                    {
                        String markup = sr.ReadToEnd();
                        markup = markup.Replace("${error}", e.Message);
                        xmlDoc.LoadXml(markup);
                    }
                }

                XmlNodeList scripts = xmlDoc.GetElementsByTagName("script");
                foreach (XmlElement elmScript in scripts)
                {
                    if (elmScript.HasAttribute("type"))
                    {
                        if (elmScript.GetAttribute("type") == "text/lua")
                        {
                            if (elmScript.HasAttribute("src"))
                            {
                                Scripting.LoadFile(elmScript.GetAttribute("src"));
                            }
                            else
                            {
                                Scripting.LoadScript(elmScript.InnerText);
                            }
                        }
                    }
                }
                if (this.Sections.Count > 0)
                {
                    this.LoadNodesAgain(xmlDoc.DocumentElement);
                }
                else
                {
                    this.LoadNodes(xmlDoc.DocumentElement);
                }
                this.tabBar.Refresh();
            }

            //catch (Exception e)
            {
                //       this.Host.OnNotify(this.Host, new NotificationEventArgs() { Text = "An error occured", Type = NotificationType.Error });
            }
        }