Exemplo n.º 1
0
        public override bool OnDeserialize(ClassPointer root, ILimnorDesigner designer)
        {
            HtmlElement_Base c = this.HtmlElement;

            if (c == null)
            {
                c = new HtmlElement_body(root);
            }
            Init(designer, c);
            return(true);
        }
Exemplo n.º 2
0
        public override void OnReadFromXmlNode(IXmlCodeReader reader, XmlNode node)
        {
            base.OnReadFromXmlNode(reader, node);
            string           guid = XmlUtil.GetAttribute(node, XmlTags.XMLATT_guid);
            XmlObjectReader  xr   = reader as XmlObjectReader;
            ClassPointer     root = xr.ObjectList.RootPointer as ClassPointer;
            HtmlElement_Base he   = null;

            if (!string.IsNullOrEmpty(guid))
            {
                he = root.FindHtmlElementByGuid(new Guid(guid));
            }
            if (he == null)
            {
                he = new HtmlElement_body(root);
            }
            this.ClassPointer = he;
        }
        public static HtmlDocument MergeXmlDocumentIntoHtml(string htmlFile, bool enablePageCache, XmlDocument xmlDoc, string saveToFile, IList <HtmlElement_BodyBase> dbhtmlElements, IList <IHtmlElementCreateContents> contentHtmlElements, string iframeId, string serverFile)
        {
            HtmlDocument htmlDoc = null;

            if (xmlDoc != null && xmlDoc.DocumentElement != null)
            {
                htmlDoc = LoadHtmlDocument(htmlFile);
                if (htmlDoc != null && htmlDoc.DocumentNode != null)
                {
                    HtmlNode htmlNode = htmlDoc.DocumentNode.SelectSingleNode("html");
                    if (htmlNode != null)
                    {
                        XmlNode xHead = xmlDoc.DocumentElement.SelectSingleNode("head");
                        if (xHead != null)
                        {
                            HtmlNode hHead = null;
                            if (htmlNode.FirstChild != null && string.Compare(htmlNode.FirstChild.Name, "head", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                hHead = htmlNode.FirstChild;
                            }
                            if (hHead == null)
                            {
                                hHead = htmlDoc.CreateElement("head");
                                if (htmlNode.FirstChild != null)
                                {
                                    htmlNode.InsertBefore(hHead, htmlNode.FirstChild);
                                }
                                else
                                {
                                    htmlNode.AppendChild(hHead);
                                }
                            }
                            if (enablePageCache)
                            {
                                for (int j = 0; j < hHead.ChildNodes.Count; j++)
                                {
                                    if (string.Compare(hHead.ChildNodes[j].Name, "meta", StringComparison.OrdinalIgnoreCase) == 0)
                                    {
                                        string val = getHtmlAttribute(hHead.ChildNodes[j], "http-equiv");
                                        if (string.Compare(val, "PRAGMA", StringComparison.OrdinalIgnoreCase) == 0)
                                        {
                                            hHead.RemoveChild(hHead.ChildNodes[j]);
                                            break;
                                        }
                                    }
                                }
                            }
                            mergeXmlHeadToHtml(htmlDoc, hHead, xHead);
                        }
                        HtmlNode hBody = htmlNode.SelectSingleNode("body");
                        if (hBody == null)
                        {
                            hBody = htmlDoc.CreateElement("body");
                            htmlNode.AppendChild(hBody);
                        }
                        else
                        {
                            if (dbhtmlElements != null && dbhtmlElements.Count > 0)
                            {
                                foreach (HtmlElement_BodyBase hbb in dbhtmlElements)
                                {
                                    HtmlElement_body body = hbb as HtmlElement_body;
                                    if (body != null)
                                    {
                                        setDataBind0(hBody, body);
                                        break;
                                    }
                                }
                                for (int i = 0; i < hBody.ChildNodes.Count; i++)
                                {
                                    setDataBind(hBody.ChildNodes[i], dbhtmlElements);
                                }
                            }
                        }
                        XmlNode xBody = xmlDoc.DocumentElement.SelectSingleNode("body");
                        if (xBody != null)
                        {
                            mergeXmlBodyToHtml(htmlDoc, hBody, xBody);
                        }
                        foreach (IHtmlElementCreateContents hecc in contentHtmlElements)
                        {
                            HtmlNode hn = hBody.SelectSingleNode(string.Format(CultureInfo.InvariantCulture,
                                                                               "//*[@id=\"{0}\"]", hecc.id));
                            if (hn != null)
                            {
                                hecc.CreateHtmlContent(hn);
                            }
                        }
                        removeLimnrId(htmlDoc.DocumentNode, iframeId, serverFile);
                        htmlDoc.Save(saveToFile);
                    }
                }
            }
            return(htmlDoc);
        }
Exemplo n.º 4
0
        public override bool IsSameElement(HtmlElement_Base e)
        {
            HtmlElement_body bd = e as HtmlElement_body;

            return(bd != null);
        }