本文整理汇总了C#中INode.GetAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:C# INode.GetAttributeValue方法的具体用法?C# INode.GetAttributeValue怎么用?C# INode.GetAttributeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.GetAttributeValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseCategoryIdInHtmlDocument
/// <exception cref="ArgumentNullException"><paramref name="categoryNode"/> is <see langword="null" />.</exception>
public string ParseCategoryIdInHtmlDocument(INode categoryNode)
{
if (categoryNode == null)
throw new ArgumentNullException("categoryNode");
var categoryIdInHtmlDocument = categoryNode.GetAttributeValue(Constants.CategoryIdAttribute);
return HttpUtility.HtmlDecode(categoryIdInHtmlDocument);
}
示例2: ParseCategoryNode
/// <exception cref="ArgumentNullException"><paramref name="categoryNode"/> is <see langword="null" />.</exception>
public PluralsightCategory ParseCategoryNode(INode categoryNode)
{
if (categoryNode == null)
throw new ArgumentNullException("categoryNode");
var idInHtml = categoryNode.GetAttributeValue(Constants.CategoryIdAttribute);
var categoryName = _nodeSelector.SelectNode(categoryNode, Constants.CategoryNameXPath).InnerText;
var courseCategory = new PluralsightCategory
{
UrlName = HttpUtility.HtmlDecode(idInHtml),
Title = HttpUtility.HtmlDecode(categoryName)
};
return courseCategory;
}
示例3: ParseSketchNode
/// <exception cref="ArgumentNullException"><paramref name="sketchNode"/> is <see langword="null" />.</exception>
public Sketch ParseSketchNode(INode sketchNode)
{
if (sketchNode == null)
throw new ArgumentNullException("sketchNode");
var sketchUrl = sketchNode.GetAttributeValue(Constants.SketchUrlAttribute);
var sketchUriBuilder = new UriBuilder(new Uri(sketchUrl))
{
Scheme = Uri.UriSchemeHttp
};
var sketchUri = sketchUriBuilder.Uri;
var sketch = new Sketch
{
Url = sketchUri.ToString(),
FileName = sketchUri.Segments.Last().EndsWith("/", StringComparison.Ordinal) ? null : sketchUri.Segments.Last()
};
return sketch;
}
示例4: ParseCourseRating
/// <exception cref="NodeParseException">Incorrect data in <paramref name="ratingNode"/>.</exception>
/// <exception cref="ArgumentNullException"><paramref name="ratingNode"/> is <see langword="null" />.</exception>
public CourseRating ParseCourseRating(INode ratingNode)
{
if (ratingNode == null)
throw new ArgumentNullException("ratingNode");
try
{
var ratingString = ratingNode.GetAttributeValue(Constants.CourseRatingAttribute);
if (ratingString.Equals("Not enough course ratings", StringComparison.OrdinalIgnoreCase))
{
return new CourseRating();
}
// context: "X.X stars from Y users" where X - Rating; Y - RaterCount
var stringParts = ratingString.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
var raters = int.Parse(stringParts[3], PositiveIntegerNumberStyle);
var rating = decimal.Parse(stringParts[0], PositiveFloatNumberStyle, NumberFormatInfo.InvariantInfo);
var courseRating = new CourseRating
{
Raters = raters,
Rating = rating
};
return courseRating;
}
// ReSharper disable once CatchAllClause
catch (Exception ex)
{
var message = string.Format(Resources.CatalogNodeParseException_Message, "ratingNode");
throw new NodeParseException(message, ratingNode.OuterText, ex);
}
}
示例5: ParseCoAuthors
/// <exception cref="ArgumentNullException"><paramref name="coAuthorNode"/> is <see langword="null" />.</exception>
public IEnumerable<PluralsightAuthor> ParseCoAuthors(INode coAuthorNode)
{
if (coAuthorNode == null)
throw new ArgumentNullException("coAuthorNode");
var coAuthors = coAuthorNode.GetAttributeValue(Constants.AuthorFullNameAttribute)
.Split(new[] {", "}, StringSplitOptions.RemoveEmptyEntries)
.Select(x => new PluralsightAuthor
{
FullName = HttpUtility.HtmlDecode(x.Trim())
});
return coAuthors;
}
示例6: ParseAuthorFullName
/// <exception cref="ArgumentNullException"><paramref name="authorNode"/> is <see langword="null" />.</exception>
public string ParseAuthorFullName(INode authorNode)
{
if (authorNode == null)
throw new ArgumentNullException("authorNode");
var authorFullName = authorNode.GetAttributeValue(Constants.AuthorFullNameAttribute);
return HttpUtility.HtmlDecode(authorFullName);
}
示例7: ParseAuthor
/// <exception cref="ArgumentNullException"><paramref name="authorNode"/> is <see langword="null" />.</exception>
public PluralsightAuthor ParseAuthor(INode authorNode)
{
if (authorNode == null)
throw new ArgumentNullException("authorNode");
var authorFullName = authorNode.GetAttributeValue(Constants.AuthorFullNameAttribute);
var authorUrl = authorNode.GetAttributeValue(Constants.AuthorUrlAttribute);
var authorUriBuilder = new UriBuilder(new Uri(authorUrl))
{
Scheme = Uri.UriSchemeHttp
};
var authorUri = authorUriBuilder.Uri;
var author = new PluralsightAuthor
{
FullName = HttpUtility.HtmlDecode(authorFullName),
SiteUrl = authorUri.ToString(),
UrlName = authorUri.Segments.Last()
};
return author;
}
示例8: ParseCourseInfo
/// <exception cref="ArgumentNullException"><paramref name="infoNode"/> is <see langword="null" />.</exception>
public CourseInfo ParseCourseInfo(INode infoNode)
{
if (infoNode == null)
throw new ArgumentNullException("infoNode");
var description = infoNode.GetAttributeValue(Constants.CourseDescriptionAttribute);
var relativeUrl = infoNode.GetAttributeValue(Constants.CourseUrlAttribute);
var amendedUrl = AmendCourseUrl(relativeUrl);
var courseUri = new Uri(_host, amendedUrl);
var courseInfo = new CourseInfo
{
Name = HttpUtility.HtmlDecode(infoNode.InnerText),
Description = HttpUtility.HtmlDecode(description),
SiteUrl = courseUri.ToString(),
UrlName = courseUri.Segments.Last()
};
return courseInfo;
}