本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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.");
}
}
示例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();
}
示例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();
}
}
示例7: ParentImpl
private IEnumerable<IDomObject> ParentImpl(IDomObject input)
{
if (input.ParentNode != null &&
input.ParentNode.NodeType == NodeType.ELEMENT_NODE)
{
yield return input.ParentNode;
}
}
示例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';
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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};
});
}