当前位置: 首页>>代码示例>>C#>>正文


C# IDomObject类代码示例

本文整理汇总了C#中IDomObject的典型用法代码示例。如果您正苦于以下问题:C# IDomObject类的具体用法?C# IDomObject怎么用?C# IDomObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IDomObject类属于命名空间,在下文中一共展示了IDomObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Matches

        /// <summary>
        /// Test whether an element is the last child of its type.
        /// </summary>
        ///
        /// <param name="element">
        /// The element to test.
        /// </param>
        ///
        /// <returns>
        /// true if it matches, false if not.
        /// </returns>

        public override bool Matches(IDomObject element)
        {

            return element.ParentNode.ChildElements
              .Where(item => item.NodeNameID == element.NodeNameID)
              .LastOrDefault() == element;
        }
开发者ID:emrahoner,项目名称:CsQuery,代码行数:19,代码来源:LastOfType.cs

示例2: Matches

        /// <summary>
        /// Test whether an element is the only element of its type among its siblings.
        /// </summary>
        ///
        /// <param name="element">
        /// The element to test.
        /// </param>
        ///
        /// <returns>
        /// true if it matches, false if not.
        /// </returns>

        public override bool Matches(IDomObject element)
        {

            return element.ParentNode.ChildElements
               .Where(item => item.NodeNameID == element.NodeNameID)
               .SingleOrDefaultAlways() != null;
        }
开发者ID:emrahoner,项目名称:CsQuery,代码行数:19,代码来源:OnlyOfType.cs

示例3: Matches

        /// <summary>
        /// Test whether an element is a parent; e.g. has children.
        /// </summary>
        ///
        /// <param name="element">
        /// The element to test.
        /// </param>
        ///
        /// <returns>
        /// true if it matches, false if not.
        /// </returns>

        public override bool Matches(IDomObject element)
        {

            return element.HasChildren ?
                !Empty.IsEmpty(element) : 
                false;
        }
开发者ID:emrahoner,项目名称:CsQuery,代码行数:19,代码来源:Parent.cs

示例4: Render

        /// <summary>
        /// Renders the object to the textwriter.
        /// </summary>
        ///
        /// <exception cref="NotImplementedException">
        /// Thrown when the requested operation is unimplemented.
        /// </exception>
        ///
        /// <param name="node">
        /// The node.
        /// </param>
        /// <param name="writer">
        /// The writer to which output is written.
        /// </param>

        public void Render(IDomObject node, TextWriter writer)
        {

            switch (node.NodeType) {
                case NodeType.ELEMENT_NODE:
                    RenderElement(node,writer,true);
                    break;
                case NodeType.DOCUMENT_FRAGMENT_NODE:
                case NodeType.DOCUMENT_NODE:
                    RenderElements(node.ChildNodes,writer);
                    break;
                case NodeType.TEXT_NODE:
                    RenderTextNode(node, writer,false);
                    break;
                case NodeType.CDATA_SECTION_NODE:
                    RenderCdataNode(node, writer);
                    break;
                case NodeType.COMMENT_NODE:
                    RenderCommentNode(node, writer);
                    break;
                case NodeType.DOCUMENT_TYPE_NODE:
                    RenderDocTypeNode(node, writer);
                    break;
                default:
                    throw new NotImplementedException("An unknown node type was found while rendering the CsQuery document.");
            }
        }
开发者ID:TheX,项目名称:CsQuery,代码行数:42,代码来源:OutputFormatterDefault.cs

示例5: IsEmpty

        /// <summary>
        /// Test whether an element contains no non-empty children. An element can technically have
        /// children, but if they are text nodes with empty values, then it's considered empty.
        /// </summary>
        ///
        /// <param name="element">
        /// The element to test
        /// </param>
        ///
        /// <returns>
        /// true if an element is empty, false if not.
        /// </returns>

        public static bool IsEmpty(IDomObject element)
        {
            return !element.ChildNodes
                   .Where(item => item.NodeType == NodeType.ELEMENT_NODE ||
                       (item.NodeType == NodeType.TEXT_NODE &&
                       !String.IsNullOrEmpty(item.NodeValue)))
                   .Any();
        }
开发者ID:emrahoner,项目名称:CsQuery,代码行数:21,代码来源:Empty.cs

示例6: Render

        /// <summary>
        /// Renders this object and returns the output as a string.
        /// </summary>
        ///
        /// <param name="node">
        /// The node.
        /// </param>
        ///
        /// <returns>
        /// A string of HTML.
        /// </returns>

        public string Render(IDomObject node)
        {
            using (StringWriter writer = new StringWriter())
            {
                Render(node, writer);
                return writer.ToString();
            }
        }
开发者ID:TheX,项目名称:CsQuery,代码行数:20,代码来源:FormatPlainText.cs

示例7: ParentImpl

 private IEnumerable<IDomObject> ParentImpl(IDomObject input)
 {
     if (input.ParentNode != null &&
         input.ParentNode.NodeType == NodeType.ELEMENT_NODE)
     {
         yield return input.ParentNode;
     }
 }
开发者ID:emrahoner,项目名称:CsQuery,代码行数:8,代码来源:Parent.cs

示例8: Matches

        /// <summary>
        /// Test whether an element is a header (H1-H6)
        /// </summary>
        ///
        /// <param name="element">
        /// The element to test.
        /// </param>
        ///
        /// <returns>
        /// true if it matches, false if not.
        /// </returns>

        public override bool Matches(IDomObject element)
        {
            var nodeName = element.NodeName;
            return nodeName[0] == 'H'
                && nodeName.Length == 2
                && nodeName[1] >= '0'
                && nodeName[1] <= '6';
        }
开发者ID:emrahoner,项目名称:CsQuery,代码行数:20,代码来源:Header.cs

示例9: AddSelection

 /// <summary>
 /// Add an item to the list of selected elements. It should be part of this DOM.
 /// </summary>
 /// <param name="element"></param>
 protected bool AddSelection(IDomObject element)
 {
     //if (!ReferenceEquals(element.Dom, Dom))
     //{
     //    throw new InvalidOperationException("Cannot add unbound elements or elements bound to another DOM directly to a selection set.");
     //}
     return SelectionSet.Add(element);
 }
开发者ID:feidianbo,项目名称:CsQuery,代码行数:12,代码来源:CQ_Internal.cs

示例10: ParseCommandsNames

 static string[] ParseCommandsNames(CQ dom, IDomObject @event)
 {
     var commands =
         dom.Select(
             "td.today-name > span.command > div.today-member-name, td.name > span.command div.member-name",
             @event).Map(node => node.Cq().Text().Trim().Replace(Nbsp, ' ')).ToArray();
     Debug.Assert(commands.Count() == 2, "Teams names have not been recognized: " + @event.InnerHTML);
     return commands;
 }
开发者ID:oreshkor,项目名称:luckybird,代码行数:9,代码来源:SoccerPageParser.cs

示例11: ParseEventDate

        static DateTimeOffset ParseEventDate(CQ dom, IDomObject @event)
        {
            var date = dom.Select("td.date", @event).Text().Trim();

            DateTimeOffset eventDate;
            DateTimeOffset.TryParse(date, out eventDate);

            return eventDate;
        }
开发者ID:oreshkor,项目名称:luckybird,代码行数:9,代码来源:SoccerPageParser.cs

示例12: FindEquivalent

        public static IList<AttributeToCss> FindEquivalent(IDomObject domobject, StyleClass styles)
        {

            return (from attributeRuleMatch in _linkedAttributes
                    where domobject.HasAttribute(attributeRuleMatch.Key) && styles.Attributes.ContainsKey(attributeRuleMatch.Value)
                    select new AttributeToCss
                        {
                            AttributeName = attributeRuleMatch.Key, CssValue = styles.Attributes[attributeRuleMatch.Value].Value
                        }).ToList();
        }
开发者ID:burningice2866,项目名称:PreMailer.Net,代码行数:10,代码来源:CssStyleEquivalence.cs

示例13: LinkTagCssSource

		public LinkTagCssSource(IDomObject node, Uri baseUri)
		{
			// There must be an href
			var href = node.Attributes.First(a => a.Key.Equals("href", StringComparison.OrdinalIgnoreCase)).Value;

			if (Uri.IsWellFormedUriString(href, UriKind.Relative) && baseUri != null)
				_downloadUri = new Uri(baseUri, href);
			else // Assume absolute
				_downloadUri = new Uri(href);
		}
开发者ID:burningice2866,项目名称:PreMailer.Net,代码行数:10,代码来源:LinkTagCssSource.cs

示例14: extractTurkceWord

 private string extractTurkceWord(IDomObject de)
 {
     // remove whitespaces and etc.
     string text = Regex.Replace(de.InnerText,@"\t|\n|\r", " ");
     // remove Square Brackets and its content
     text = Regex.Replace(text,@"\[[^\]]*\]",""); // \[ [ ^ \] ]* \]
     // get string before before Colon
     Regex re = new Regex(@"[^\:]*(?=\:)");
     text = re.Match(text).ToString().Trim();
     return text;
 }
开发者ID:aytacyildiz,项目名称:lazcasozlukfetcher,代码行数:11,代码来源:Program.cs

示例15: ParseEvents

 static IEnumerable<ParsedEventData> ParseEvents(CQ dom, IDomObject @event)
 {
     return dom.Select("td.js-price", @event)
               .Map(node =>
                        {
                            var domNode = node.Cq();
                            var coefficient = double.Parse(domNode.Find("span.selection-link").Text().Trim());
                            var specification = domNode.Children().Remove().End().Text().Trim();
                            return new ParsedEventData {Coefficient = coefficient, Specification = specification};
                        });
 }
开发者ID:oreshkor,项目名称:luckybird,代码行数:11,代码来源:SoccerPageParser.cs


注:本文中的IDomObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。