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


C# INode.GetAttributeValue方法代码示例

本文整理汇总了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);
      }
开发者ID:ssh-git,项目名称:training-manager,代码行数:10,代码来源:PluralsightNodeParser.cs

示例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;
      }
开发者ID:ssh-git,项目名称:training-manager,代码行数:18,代码来源:PluralsightNodeParser.cs

示例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;
      }
开发者ID:ssh-git,项目名称:training-manager,代码行数:22,代码来源:PluralsightNodeParser.cs

示例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);
         }
      }
开发者ID:ssh-git,项目名称:training-manager,代码行数:34,代码来源:PluralsightNodeParser.cs

示例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;
      }
开发者ID:ssh-git,项目名称:training-manager,代码行数:15,代码来源:PluralsightNodeParser.cs

示例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);
      }
开发者ID:ssh-git,项目名称:training-manager,代码行数:10,代码来源:PluralsightNodeParser.cs

示例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;
      }
开发者ID:ssh-git,项目名称:training-manager,代码行数:24,代码来源:PluralsightNodeParser.cs

示例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;
      }
开发者ID:ssh-git,项目名称:training-manager,代码行数:23,代码来源:PluralsightNodeParser.cs


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