コード例 #1
0
    public void ParseSection2()
    {
      // Start and End for tag
      HtmlSectionTemplate template = new HtmlSectionTemplate();
      template.Tags = "T";
      template.Template =
        "<table><tr><td>Title:<#TITLE>(</td><td><#START></td><td><#DESCRIPTION></td><Z(><td><#GENRE></td></Z)?></tr></table>";

      HtmlSectionParser elements = new HtmlSectionParser(template);

      ParserData data = new ParserData();
      IParserData idata = (IParserData)data;
      string source = "<table><tr><td>Test</td><td>123</td><td>blah blah</td></tr></table>";
      elements.ParseSection(source, ref idata);

      Assert.IsTrue(data.GetElement("#TITLE") == "Test");
      Assert.IsTrue(data.GetElement("#START") == "123");
      Assert.IsTrue(data.GetElement("#DESCRIPTION") == "blah blah");

      data = new ParserData();
      idata = (IParserData)data;
      source = "<table><tr><td>Title:Test(1:2)</td><td>123</td><td>blah blah</td></tr></table>";
      elements.ParseSection(source, ref idata);

      Assert.IsTrue(data.GetElement("#TITLE") == "Test");
      Assert.IsTrue(data.GetElement("#START") == "123");
      Assert.IsTrue(data.GetElement("#DESCRIPTION") == "blah blah");
    }
コード例 #2
0
    public void MatchCount()
    {
      HtmlProfiler profiler;
      int count;

      // Normal test
      HtmlSectionTemplate template = new HtmlSectionTemplate();
      template.Tags = "T";
      template.Template = "<table><tr><td>Test</td><td>1</td><td>2</td></tr></table>";
      profiler = new HtmlProfiler(template);

      count =
        profiler.MatchCount(
          "<table><tr><td>Test</td><td>1</td><td>2</td></tr></table><div><div><div><table><tr><td>Test</td><td>1</td><td>2</td></tr></table><span><span><span><table><tr><td>Test</td><td>1</td><td>2</td><td>3</td></tr></table>");

      Assert.IsTrue(count == 2);

      // Regex test
      template.Template = "<table><tr><td>Test</td><td>1</td><td>2</td><Z(><td>3</td></Z)?></tr></table>";
      profiler = new HtmlProfiler(template);

      count =
        profiler.MatchCount(
          "<table><tr><td>Test</td><td>1</td><td>2</td></tr></table><div><div><div><table><tr><td>Test</td><td>1</td><td>2</td></tr></table><span><span><span><table><tr><td>Test</td><td>1</td><td>2</td><td>3</td></tr></table>");

      Assert.IsTrue(count == 3);
    }
コード例 #3
0
    public void ParseSection3()
    {
      // Multiple tags
      HtmlSectionTemplate template = new HtmlSectionTemplate();
      template.Tags = "T";
      template.Template =
        "<table><tr><td><#TITLE>-<#SUBTITLE></td><td><#START></td><td><#DESCRIPTION></td><Z(><td><#GENRE></td></Z)?></tr></table>";

      HtmlSectionParser elements = new HtmlSectionParser(template);
      ParserData data = new ParserData();
      IParserData idata = (IParserData)data;
      string source = "<table><tr><td>Test-Sub</td><td>123</td><td>blah blah</td></tr></table>";
      elements.ParseSection(source, ref idata);

      Assert.IsTrue(data.GetElement("#TITLE") == "Test");
      Assert.IsTrue(data.GetElement("#SUBTITLE") == "Sub");
      Assert.IsTrue(data.GetElement("#START") == "123");
      Assert.IsTrue(data.GetElement("#DESCRIPTION") == "blah blah");
    }
コード例 #4
0
ファイル: HtmlProfiler.cs プロジェクト: arangas/MediaPortal-1
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlProfiler"/> class.
 /// </summary>
 /// <param name="template">The template.</param>
 public HtmlProfiler(HtmlSectionTemplate template)
 {
   _sectionTemplate = template;
   _template = BuildProfile(_sectionTemplate.Template);
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlSectionParser"/> class.
 /// </summary>
 /// <param name="template">The template.</param>
 public HtmlSectionParser(HtmlSectionTemplate template)
 {
   _template = template;
   _template.Tags = template.Tags + "Z";
   _templateData = GetSections(template.Template);
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlProfiler"/> class.
 /// </summary>
 /// <param name="template">The template.</param>
 public HtmlProfiler(HtmlSectionTemplate template)
 {
     _sectionTemplate = template;
     _template        = BuildProfile(_sectionTemplate.Template);
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlSectionParser"/> class.
 /// </summary>
 /// <param name="template">The template.</param>
 public HtmlSectionParser(HtmlSectionTemplate template)
 {
     _template      = template;
     _template.Tags = template.Tags + "Z";
     _templateData  = GetSections(template.Template);
 }