Exemplo n.º 1
0
        /// <summary>
        /// Merge options with defaults when needed
        /// </summary>
        ///
        /// <param name="options">
        /// (optional) options for controlling the operation.
        /// </param>

        private static void MergeOptions(ref DomRenderingOptions options)
        {
            if (options.HasFlag(DomRenderingOptions.Default))
            {
                options = CsQuery.Config.DomRenderingOptions | options & ~(DomRenderingOptions.Default);
            }
        }
Exemplo n.º 2
0
        protected void GetHtml(DomRenderingOptions options, StringBuilder sb, bool includeChildren)
        {
            bool quoteAll = options.HasFlag(DomRenderingOptions.QuoteAllAttributes);

            sb.Append("<");
            sb.Append(NodeName);
            // put ID first. Must use GetAttribute since the Id property defaults to ""
            string id = GetAttribute(DomData.IDAttrId, null);

            if (id != null)
            {
                sb.Append(" ");
                RenderAttribute(sb, "id", id, quoteAll);
            }
            if (_Style != null && Style.Count > 0)
            {
                sb.Append(" style=\"");
                sb.Append(Style.ToString());
                sb.Append("\"");
            }
            if (HasClasses)
            {
                sb.Append(" class=\"");
                sb.Append(ClassName);
                sb.Append("\"");
            }

            if (_Attributes != null)
            {
                foreach (var kvp in _Attributes)
                {
                    if (kvp.Key != "id")
                    {
                        sb.Append(" ");
                        RenderAttribute(sb, kvp.Key, kvp.Value, quoteAll);
                    }
                }
            }
            if (InnerHtmlAllowed || InnerTextAllowed)
            {
                sb.Append(">");
                if (includeChildren)
                {
                    base.Render(sb, options);
                }
                else
                {
                    sb.Append(HasChildren ?
                              "..." :
                              String.Empty);
                }
                sb.Append("</");
                sb.Append(NodeName);
                sb.Append(">");
            }
            else
            {
                if ((Document == null ? CQ.DefaultDocType : Document.DocType) == DocType.XHTML)
                {
                    sb.Append(" />");
                }
                else
                {
                    sb.Append(">");
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Merge options with defaults when needed
        /// </summary>
        ///
        /// <param name="options">
        /// (optional) options for controlling the operation.
        /// </param>

        private static void MergeOptions(ref DomRenderingOptions options)
        {
            if (options.HasFlag(DomRenderingOptions.Default))
            {
                options = CsQuery.Config.DomRenderingOptions | options & ~(DomRenderingOptions.Default);
            }
        }