14 new revisions:
Revision: 073aa958b22b
Branch: default
Author: azizatif
Date: Wed Sep 30 23:20:04 2009
Log: Fixed issue #24, "QuerySelectorAll on HtmlNode fro FORM returns 0
node...
http://code.google.com/p/fizzler/source/detail?r=073aa958b22b
Revision: 92954711ba24
Branch: default
Author: azizatif
Date: Sat Oct 31 12:13:41 2009
Log: Replaced BackLINQ with LINQBridge since they one and the same now
whil...
http://code.google.com/p/fizzler/source/detail?r=92954711ba24
Revision: f9d417bd3b79
Branch: default
Author: azizatif
Date: Sat Oct 31 12:19:36 2009
Log: Updated Parser.Parse to be able to return the result, which could
be t...
http://code.google.com/p/fizzler/source/detail?r=f9d417bd3b79
Revision: 9600c57e20ba
Branch: default
Author: azizatif
Date: Wed Nov 11 17:13:55 2009
Log: Added support for compiling selectors as well as cached
compilations t...
http://code.google.com/p/fizzler/source/detail?r=9600c57e20ba
Revision: 0193cd3fd75d
Branch: default
Author: azizatif
Date: Mon Feb 1 15:08:10 2010
Log: Fixed issue #38, "Visual Fizzler decodes HTML response
incorrectly."
http://code.google.com/p/fizzler/source/detail?r=0193cd3fd75d
Revision: 831c4696e90a
Branch: default
Author: azizatif
Date: Tue Feb 2 14:12:36 2010
Log: Fixed license region in SolutionInfo.cs.
http://code.google.com/p/fizzler/source/detail?r=831c4696e90a
Revision: 8eb741921502
Branch: default
Author: azizatif
Date: Tue Feb 2 14:28:39 2010
Log: Moved imports inside namespace declarations.
http://code.google.com/p/fizzler/source/detail?r=8eb741921502
Revision: 978fa1985ace
Branch: default
Author: azizatif
Date: Tue Feb 2 14:46:14 2010
Log: Updated ConsoleFizzler to use string extensions from Mannex.
http://code.google.com/p/fizzler/source/detail?r=978fa1985ace
Revision: cb8d492a9209
Branch: default
Author: azizatif
Date: Wed Oct 6 16:15:18 2010
Log: Implemented issue #27, "Support nth-last-child pseudo-class
selector",...
http://code.google.com/p/fizzler/source/detail?r=cb8d492a9209
Revision: c69bc5ee728d
Branch: default
Author: azizatif
Date: Wed Oct 6 16:24:09 2010
Log: Fixed typo in exception message.
http://code.google.com/p/fizzler/source/detail?r=c69bc5ee728d
Revision: 895f6368aba0
Branch: default
Author: azizatif
Date: Wed Oct 6 16:28:04 2010
Log: Removed duplication in parsing the b component between Parser.Nth
and ...
http://code.google.com/p/fizzler/source/detail?r=895f6368aba0
Revision: efb2858f4429
Branch: default
Author: azizatif
Date: Wed Oct 6 16:35:37 2010
Log: Fixed formatting/indentation issues due to mixed use of tabs and
space...
http://code.google.com/p/fizzler/source/detail?r=efb2858f4429
Revision: 854aa970f9cc
Branch: default
Author: azizatif
Date: Wed Oct 6 16:42:39 2010
Log: Fixed typos in exception messages.
http://code.google.com/p/fizzler/source/detail?r=854aa970f9cc
Revision: 41f2faaf12bc
Branch: default
Author: convert-repo
Date: Thu Jan 3 14:27:26 2013
Log: update tags
http://code.google.com/p/fizzler/source/detail?r=41f2faaf12bc
==============================================================================
Revision: 073aa958b22b
Branch: default
Author: azizatif
Date: Wed Sep 30 23:20:04 2009
Log: Fixed issue #24, "QuerySelectorAll on HtmlNode fro FORM returns 0
nodes child INPUTs."
http://code.google.com/p/fizzler/source/detail?r=073aa958b22b
Added:
/Fizzler.Systems.HtmlAgilityPack/HtmlDocumentExtensions.cs
Modified:
/ConsoleFizzler/SelectCommand.cs
/Fizzler.Systems.HtmlAgilityPack/Fizzler.Systems.HtmlAgilityPack.csproj
/Fizzler.Tests/ElementSelector.cs
/Fizzler.Tests/PsuedoSelectors.cs
/Fizzler.Tests/SelectorBaseTest.cs
/NET-2.0/Fizzler.Systems.HtmlAgilityPack.csproj
/VisualFizzler/MainForm.cs
=======================================
--- /dev/null
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlDocumentExtensions.cs Wed Sep 30
23:20:04 2009
@@ -0,0 +1,104 @@
+using System;
+using System.Collections;
+using System.Runtime.CompilerServices;
+using HtmlAgilityPack;
+
+namespace Fizzler.Systems.HtmlAgilityPack
+{
+ public static class HtmlDocumentExtensions
+ {
+ private static Hashtable _defaultElementFlags;
+
+ // TODO Think of a better name than LoadHtml2
+ /// <summary>
+ /// Same as <see cref="HtmlDocument.LoadHtml" /> but without the
FORM nesting
+ /// problem outlined in <a
href="
http://code.google.com/p/fizzler/issues/detail?id=24">issue #24</a>.
+ /// </summary>
+
+ public static void LoadHtml2(this HtmlDocument document, string
html)
+ {
+ if (document == null) throw new
ArgumentNullException("document");
+ document.LoadHtmlWithElementFlags(html, DefaultElementFlags);
+ }
+
+ // TODO Think of a better name than LoadHtml2
+ /// <summary>
+ /// Same as <see cref="HtmlDocument.Load" /> but without the FORM
nesting
+ /// problem outlined in <a
href="
http://code.google.com/p/fizzler/issues/detail?id=24">issue #24</a>.
+ /// </summary>
+
+ public static void Load2(this HtmlDocument document, string path)
+ {
+ if (document == null) throw new
ArgumentNullException("document");
+ document.LoadWithElementFlags(path, DefaultElementFlags);
+ }
+
+ /// <summary>
+ /// Parses the HTML and loads the document model using supplied
+ /// per-element handling options.
+ /// </summary>
+ /// <remarks>
+ /// The behavior of this method is not guaranteed to be thread-safe
+ /// and is primarily a hack around <see
cref="HtmlNode.ElementsFlags"/>
+ /// being static.
+ /// </remarks>
+
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ public static void LoadHtmlWithElementFlags(this HtmlDocument
document, string html, Hashtable flags)
+ {
+ if (document == null) throw new
ArgumentNullException("document");
+ LoadWithElementFlags(flags, () => document.LoadHtml(html));
+ }
+
+ /// <summary>
+ /// Parses the HTML and loads the document model using supplied
+ /// per-element handling options.
+ /// </summary>
+ /// <remarks>
+ /// The behavior of this method is not guaranteed to be thread-safe
+ /// and is primarily a hack around <see
cref="HtmlNode.ElementsFlags"/>
+ /// being static.
+ /// </remarks>
+
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ public static void LoadWithElementFlags(this HtmlDocument
document, string path, Hashtable flags)
+ {
+ if (document == null) throw new
ArgumentNullException("document");
+ LoadWithElementFlags(flags, () => document.Load(path));
+ }
+
+ private delegate void LoadHandler();
+
+ private static void LoadWithElementFlags(Hashtable flags,
LoadHandler loader)
+ {
+ var oldFlags = HtmlNode.ElementsFlags;
+ try
+ {
+ if (flags != null)
+ HtmlNode.ElementsFlags = flags;
+ loader();
+ }
+ finally
+ {
+ HtmlNode.ElementsFlags = oldFlags;
+ }
+ }
+
+ private static Hashtable DefaultElementFlags
+ {
+ get
+ {
+ if (_defaultElementFlags == null)
+ {
+ var flags = (Hashtable)HtmlNode.ElementsFlags.Clone();
+ // ReSharper disable BitwiseOperatorOnEnumWihtoutFlags
+ flags["form"] = ((HtmlElementFlag)flags["form"]) |
HtmlElementFlag.Closed;
+ // ReSharper restore BitwiseOperatorOnEnumWihtoutFlags
+ _defaultElementFlags = flags;
+ }
+
+ return _defaultElementFlags;
+ }
+ }
+ }
+}
=======================================
--- /ConsoleFizzler/SelectCommand.cs Thu Apr 30 10:50:13 2009
+++ /ConsoleFizzler/SelectCommand.cs Wed Sep 30 23:20:04 2009
@@ -44,9 +44,9 @@
var document = new HtmlDocument();
if(!arg.MoveNext() || arg.Current == "-")
- document.LoadHtml(Console.In.ReadToEnd());
+ document.LoadHtml2(Console.In.ReadToEnd());
else
- document.Load(arg.Current);
+ document.Load2(arg.Current);
var i = 0;
foreach (var node in
document.DocumentNode.QuerySelectorAll(selector))
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/Fizzler.Systems.HtmlAgilityPack.csproj
Fri May 1 06:06:07 2009
+++ /Fizzler.Systems.HtmlAgilityPack/Fizzler.Systems.HtmlAgilityPack.csproj
Wed Sep 30 23:20:04 2009
@@ -48,6 +48,7 @@
<Compile Include="..\Common\SolutionInfo.cs">
<Link>SolutionInfo.cs</Link>
</Compile>
+ <Compile Include="HtmlDocumentExtensions.cs" />
<Compile Include="HtmlNodeExtensions.cs" />
<Compile Include="HtmlNodeOps.cs" />
<Compile Include="HtmlNodeSelection.cs" />
=======================================
--- /Fizzler.Tests/ElementSelector.cs Wed Sep 30 12:42:22 2009
+++ /Fizzler.Tests/ElementSelector.cs Wed Sep 30 23:20:04 2009
@@ -62,7 +62,7 @@
/// <summary>
/// This test covers an issue with HtmlAgilityPack where form
childnodes().length == 0.
/// </summary>
- [Test,
Ignore("
http://code.google.com/p/fizzler/issues/detail?id=24")]
+ [Test]
public void Basic_Positive_Precedence_Within_Form()
{
Assert.AreEqual(1, SelectList("form input").Count);
=======================================
--- /Fizzler.Tests/PsuedoSelectors.cs Wed Sep 30 12:42:22 2009
+++ /Fizzler.Tests/PsuedoSelectors.cs Wed Sep 30 23:20:04 2009
@@ -2,7 +2,7 @@
namespace Fizzler.Tests
{
- [TestFixture,
Ignore("
http://code.google.com/p/fizzler/issues/detail?id=24")]
+ [TestFixture]
public class PsuedoSelectors : SelectorBaseTest
{
[Test]
=======================================
--- /Fizzler.Tests/SelectorBaseTest.cs Wed Sep 30 10:53:50 2009
+++ /Fizzler.Tests/SelectorBaseTest.cs Wed Sep 30 23:20:04 2009
@@ -24,7 +24,7 @@
html = reader.ReadToEnd();
}
var document = new HtmlDocument();
- document.LoadHtml(html);
+ document.LoadHtml2(html);
Document = document;
}
@@ -39,5 +39,5 @@
{
return new
ReadOnlyCollection<HtmlNode>(Select(selectorChain).ToArray());
}
- }
+ }
}
=======================================
--- /NET-2.0/Fizzler.Systems.HtmlAgilityPack.csproj Fri May 1 08:13:11 2009
+++ /NET-2.0/Fizzler.Systems.HtmlAgilityPack.csproj Wed Sep 30 23:20:04 2009
@@ -53,6 +53,9 @@
<Compile Include="..\Common\SolutionInfo.cs">
<Link>SolutionInfo.cs</Link>
</Compile>
+ <Compile
Include="..\Fizzler.Systems.HtmlAgilityPack\HtmlDocumentExtensions.cs">
+ <Link>HtmlDocumentExtensions.cs</Link>
+ </Compile>
<Compile
Include="..\Fizzler.Systems.HtmlAgilityPack\HtmlNodeExtensions.cs" />
<Compile Include="..\Fizzler.Systems.HtmlAgilityPack\HtmlNodeOps.cs" />
<Compile
Include="..\Fizzler.Systems.HtmlAgilityPack\HtmlNodeSelection.cs" />
=======================================
--- /VisualFizzler/MainForm.cs Fri May 1 10:06:40 2009
+++ /VisualFizzler/MainForm.cs Wed Sep 30 23:20:04 2009
@@ -44,7 +44,7 @@
return;
var document = new HtmlDocument();
- document.Load(_openFileDialog.FileName);
+ document.Load2(_openFileDialog.FileName);
Open(document);
}
@@ -168,7 +168,7 @@
using (CurrentCursorScope.EnterWait())
{
var document = new HtmlDocument();
- document.LoadHtml(content);
+ document.LoadHtml2(content);
Open(document);
}
==============================================================================
Revision: 92954711ba24
Branch: default
Author: azizatif
Date: Sat Oct 31 12:13:41 2009
Log: Replaced BackLINQ with LINQBridge since they one and the same now
while also addressing a CLS compliance issue.
http://code.google.com/p/fizzler/source/detail?r=92954711ba24
Added:
/Libs/LinqBridge.dll
/Libs/LinqBridge.pdb
Deleted:
/Libs/BackLinq.dll
Modified:
/NET-2.0/Fizzler.csproj
/default.build
=======================================
--- /dev/null
+++ /Libs/LinqBridge.dll Sat Oct 31 12:13:41 2009
Binary file, no diff available.
=======================================
--- /dev/null
+++ /Libs/LinqBridge.pdb Sat Oct 31 12:13:41 2009
Binary file, no diff available.
=======================================
--- /Libs/BackLinq.dll Tue Apr 28 01:19:41 2009
+++ /dev/null
Binary file, no diff available.
=======================================
--- /NET-2.0/Fizzler.csproj Wed Jun 3 13:26:53 2009
+++ /NET-2.0/Fizzler.csproj Sat Oct 31 12:13:41 2009
@@ -37,9 +37,9 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
- <Reference Include="BackLinq, Version=1.0.0.0, Culture=neutral,
processorArchitecture=MSIL">
+ <Reference Include="LinqBridge, Version=1.1.0.0, Culture=neutral,
PublicKeyToken=c2b14eb747628076, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\Libs\BackLinq.dll</HintPath>
+ <HintPath>..\Libs\LinqBridge.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
=======================================
--- /default.build Wed Sep 30 11:37:13 2009
+++ /default.build Sat Oct 31 12:13:41 2009
@@ -68,7 +68,7 @@
<references>
<include name="System.dll" />
<include name="System.Core.dll" if="${bool::parse(net-35)}" />
- <include name="libs/BackLINQ.dll" unless="${bool::parse(net-35)}" />
+ <include name="libs/LinqBridge.dll" unless="${bool::parse(net-35)}" />
</references>
</csc>
</target>
@@ -84,7 +84,7 @@
<include name="libs/HtmlAgilityPack.dll" />
<include name="System.dll" />
<include name="System.Core.dll" if="${bool::parse(net-35)}" />
- <include name="libs/BackLINQ.dll" unless="${bool::parse(net-35)}" />
+ <include name="libs/LinqBridge.dll" unless="${bool::parse(net-35)}" />
<include name="System.XML.dll" />
</references>
</csc>
@@ -102,7 +102,7 @@
<include name="libs/HtmlAgilityPack.dll" />
<include name="System.dll" />
<include name="System.Core.dll" if="${bool::parse(net-35)}" />
- <include name="libs/BackLINQ.dll" unless="${bool::parse(net-35)}" />
+ <include name="libs/LinqBridge.dll" unless="${bool::parse(net-35)}" />
<include name="System.XML.dll" />
<include name="System.Configuration.dll" />
</references>
@@ -125,7 +125,7 @@
<include name="Microsoft.VisualBasic.dll" />
<include name="System.dll" />
<include name="System.Core.dll" if="${bool::parse(net-35)}" />
- <include name="libs/BackLINQ.dll" unless="${bool::parse(net-35)}" />
+ <include name="libs/LinqBridge.dll" unless="${bool::parse(net-35)}" />
<include name="System.Deployment.dll" />
<include name="System.Drawing.dll" />
<include name="System.Windows.Forms.dll" />
@@ -149,14 +149,14 @@
<include name="libs\nunit.framework.dll" />
<include name="System.dll" />
<include name="System.Core.dll" if="${bool::parse(net-35)}" />
- <include name="libs/BackLINQ.dll" unless="${bool::parse(net-35)}" />
+ <include name="libs/LinqBridge.dll" unless="${bool::parse(net-35)}" />
<include name="System.XML.dll" />
</references>
</csc>
</target>
<target name="test" depends="build-tests">
<copy file="libs/HtmlAgilityPack.dll"
todir="bin//${output.dir}${configuration}" />
- <copy file="libs/BackLINQ.dll"
todir="bin//${output.dir}${configuration}" unless="${bool::parse(net-35)}"
/>
+ <copy file="libs/LinqBridge.dll"
todir="bin//${output.dir}${configuration}" unless="${bool::parse(net-35)}"
/>
<copy file="libs/nunit.framework.dll"
todir="bin//${output.dir}${configuration}" />
<nunit2>
<formatter type="Plain" />
==============================================================================
Revision: f9d417bd3b79
Branch: default
Author: azizatif
Date: Sat Oct 31 12:19:36 2009
Log: Updated Parser.Parse to be able to return the result, which could
be the generator or user-defined.
http://code.google.com/p/fizzler/source/detail?r=f9d417bd3b79
Modified:
/Fizzler.Systems.HtmlAgilityPack/HtmlNodeSelection.cs
/Fizzler/Parser.cs
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/HtmlNodeSelection.cs Mon Apr 27
17:45:09 2009
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlNodeSelection.cs Sat Oct 31
12:19:36 2009
@@ -28,9 +28,8 @@
/// </summary>
public static IEnumerable<HtmlNode> QuerySelectorAll(this HtmlNode
node, string selector)
{
- var generator = new SelectorGenerator<HtmlNode>(new
HtmlNodeOps());
- Parser.Parse(selector, generator);
- return generator.Selector(Enumerable.Repeat(node, 1));
+ return Parser.Parse(selector, new
SelectorGenerator<HtmlNode>(new HtmlNodeOps()))
+ .Selector(Enumerable.Repeat(node, 1));
}
}
}
=======================================
--- /Fizzler/Parser.cs Wed Jun 3 13:26:53 2009
+++ /Fizzler/Parser.cs Sat Oct 31 12:19:36 2009
@@ -27,21 +27,46 @@
/// <summary>
/// Parses a CSS selector group and generates its implementation.
/// </summary>
- public static void Parse(string selectors, ISelectorGenerator
generator)
+ public static TGenerator Parse<TGenerator>(string selectors,
TGenerator generator)
+ where TGenerator : ISelectorGenerator
+ {
+ return Parse(selectors, generator, g => g);
+ }
+
+ /// <summary>
+ /// Parses a CSS selector group and generates its implementation.
+ /// </summary>
+ public static T Parse<TGenerator, T>(string selectors, TGenerator
generator, Func<TGenerator, T> resultor)
+ where TGenerator : ISelectorGenerator
{
if (selectors == null) throw new
ArgumentNullException("selectors");
if (selectors.Length == 0) throw new
ArgumentException(null, "selectors");
- Parse(Tokener.Tokenize(selectors), generator);
+
+ return Parse(Tokener.Tokenize(selectors), generator, resultor);
}
/// <summary>
/// Parses a tokenized stream representing a CSS selector group and
/// generates its implementation.
/// </summary>
- public static void Parse(IEnumerable<Token> tokens,
ISelectorGenerator generator)
+ public static TGenerator Parse<TGenerator>(IEnumerable<Token>
tokens, TGenerator generator)
+ where TGenerator : ISelectorGenerator
+ {
+ return Parse(tokens, generator, g => g);
+ }
+
+ /// <summary>
+ /// Parses a tokenized stream representing a CSS selector group and
+ /// generates its implementation.
+ /// </summary>
+ public static T Parse<TGenerator, T>(IEnumerable<Token> tokens,
TGenerator generator, Func<TGenerator, T> resultor)
+ where TGenerator : ISelectorGenerator
{
if (tokens == null) throw new ArgumentNullException("tokens");
+ if(resultor == null) throw new
ArgumentNullException("resultor");
+
new Parser(new Reader<Token>(tokens.GetEnumerator()),
generator).Parse();
+ return resultor(generator);
}
private void Parse()
==============================================================================
Revision: 9600c57e20ba
Branch: default
Author: azizatif
Date: Wed Nov 11 17:13:55 2009
Log: Added support for compiling selectors as well as cached
compilations to speed up frequently used selectors (by avoiding the parsing
and compilation steps on subsequent uses). Unit tests pending.
http://code.google.com/p/fizzler/source/detail?r=9600c57e20ba
Added:
/Fizzler/SelectorsCachingCompiler.cs
Modified:
/Fizzler.Systems.HtmlAgilityPack/HtmlNodeSelection.cs
/Fizzler.Systems.HtmlAgilityPack/Properties/AssemblyInfo.cs
/Fizzler/Fizzler.csproj
/Fizzler/Properties/AssemblyInfo.cs
/NET-2.0/Fizzler.Systems.HtmlAgilityPack.csproj
/NET-2.0/Fizzler.Tests.csproj
/NET-2.0/Fizzler.csproj
=======================================
--- /dev/null
+++ /Fizzler/SelectorsCachingCompiler.cs Wed Nov 11 17:13:55 2009
@@ -0,0 +1,59 @@
+using System.Diagnostics;
+
+namespace Fizzler
+{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ #endregion
+
+ /// <summary>
+ /// Implementation for a selectors compiler that supports caching.
+ /// </summary>
+ /// <remarks>
+ /// This class is primarily targeted for developers of selection
+ /// over an arbitrary document model.
+ /// </remarks>
+ public static class SelectorsCachingCompiler
+ {
+ /// <summary>
+ /// Creates a caching selectors compiler on top on an existing
compiler.
+ /// </summary>
+ public static Func<string, T> Create<T>(Func<string, T> compiler)
+ {
+ return Create(compiler, null);
+ }
+
+ /// <summary>
+ /// Creates a caching selectors compiler on top on an existing
compiler.
+ /// An addition parameter specified a dictionary to use as the
cache.
+ /// </summary>
+ /// <remarks>
+ /// If <paramref name="cache"/> is <c>null</c> then this method
uses a
+ /// the <see cref="Dictionary{TKey,TValue}"/> implementation with
an
+ /// ordinally case-insensitive selectors text comparer.
+ /// </remarks>
+ public static Func<string, T> Create<T>(Func<string, T> compiler,
IDictionary<string, T> cache)
+ {
+ if(compiler == null) throw new
ArgumentNullException("compiler");
+ return CreateImpl(compiler, cache ?? new Dictionary<string,
T>(StringComparer.OrdinalIgnoreCase));
+ }
+
+ private static Func<string, T> CreateImpl<T>(Func<string, T>
compiler, IDictionary<string, T> cache)
+ {
+ Debug.Assert(compiler != null);
+ Debug.Assert(cache != null);
+
+ return selector =>
+ {
+ T compiled;
+ return cache.TryGetValue(selector, out compiled)
+ ? compiled
+ : cache[selector] = compiler(selector);
+ };
+ }
+ }
+}
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/HtmlNodeSelection.cs Sat Oct 31
12:19:36 2009
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlNodeSelection.cs Wed Nov 11
17:13:55 2009
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
using HtmlAgilityPack;
@@ -12,9 +13,12 @@
/// </remarks>
public static class HtmlNodeSelection
{
+ private static readonly HtmlNodeOps _ops = new HtmlNodeOps();
+
/// <summary>
- /// Similar to <see cref="QuerySelectorAll" /> except it returns
- /// only the first element matching the supplied selector strings.
+ /// Similar to <see cref="QuerySelectorAll(HtmlNode,string)" />
+ /// except it returns only the first element matching the supplied
+ /// selector strings.
/// </summary>
public static HtmlNode QuerySelector(this HtmlNode node, string
selector)
{
@@ -28,8 +32,84 @@
/// </summary>
public static IEnumerable<HtmlNode> QuerySelectorAll(this HtmlNode
node, string selector)
{
- return Parser.Parse(selector, new
SelectorGenerator<HtmlNode>(new HtmlNodeOps()))
- .Selector(Enumerable.Repeat(node, 1));
+ return QuerySelectorAll(node, selector, null);
+ }
+
+ /// <summary>
+ /// Retrieves all element nodes from descendants of the starting
+ /// element node that match any selector within the supplied
+ /// selector strings. An additional parameter specifies a
+ /// particular compiler to use for parsing and compiling the
+ /// selector.
+ /// </summary>
+ /// <remarks>
+ /// The <paramref name="compiler"/> can be <c>null</c>, in which
+ /// case a default compiler is used. If the selector is to be used
+ /// often, it is recommended to use a caching compiler such as the
+ /// one supplied by <see cref="CreateCachingCompiler()"/>.
+ /// </remarks>
+ public static IEnumerable<HtmlNode> QuerySelectorAll(this HtmlNode
node, string selector, Func<string, Func<HtmlNode, IEnumerable<HtmlNode>>>
compiler)
+ {
+ return (compiler ?? Compile)(selector)(node);
+ }
+
+ /// <summary>
+ /// Parses and compiles CSS selector text into run-time function.
+ /// </summary>
+ /// <remarks>
+ /// Use this method to compile and reuse frequently used CSS
selectors
+ /// without parsing them each time.
+ /// </remarks>
+ public static Func<HtmlNode, IEnumerable<HtmlNode>> Compile(string
selector)
+ {
+ var compiled = Parser.Parse(selector, new
SelectorGenerator<HtmlNode>(_ops)).Selector;
+ return node => compiled(Enumerable.Repeat(node, 1));
+ }
+
+ //
+ // Caching
+ //
+
+ [ThreadStatic]
+ private static readonly Func<string, Func<HtmlNode,
IEnumerable<HtmlNode>>> _defaultCachingCompiler = CreateCachingCompiler();
+
+ /// <summary>
+ /// Compiles a selector. If the selector has been previously
+ /// compiled then this method returns it rather than parsing
+ /// and compiling the selector on each invocation.
+ /// </summary>
+ /// <remarks>
+ /// The cache is per-thread and therefore thread-safe without
+ /// lock contention.
+ /// </remarks>
+ public static Func<HtmlNode, IEnumerable<HtmlNode>>
CachableCompile(string selector)
+ {
+ return _defaultCachingCompiler(selector);
+ }
+
+ /// <summary>
+ /// Creates a caching selector compiler that uses a default
+ /// cache strategy when the selector text is regarded as being
+ /// orginally case-insensitive.
+ /// </summary>
+ public static Func<string, Func<HtmlNode, IEnumerable<HtmlNode>>>
CreateCachingCompiler()
+ {
+ return CreateCachingCompiler(null);
+ }
+
+ /// <summary>
+ /// Creates a caching selector compiler where the compiled
selectors
+ /// are maintained in a user-supplied <see
cref="IDictionary{TKey,TValue}"/>
+ /// instance.
+ /// </summary>
+ /// <remarks>
+ /// If <paramref name="cache"/> is <c>null</c> then this method
uses a
+ /// the <see cref="Dictionary{TKey,TValue}"/> implementation with
an
+ /// ordinally case-insensitive selectors text comparer.
+ /// </remarks>
+ public static Func<string, Func<HtmlNode, IEnumerable<HtmlNode>>>
CreateCachingCompiler(IDictionary<string, Func<HtmlNode,
IEnumerable<HtmlNode>>> cache)
+ {
+ return SelectorsCachingCompiler.Create(Compile, cache);
}
}
}
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/Properties/AssemblyInfo.cs Fri May 1
06:06:07 2009
+++ /Fizzler.Systems.HtmlAgilityPack/Properties/AssemblyInfo.cs Wed Nov 11
17:13:55 2009
@@ -7,4 +7,4 @@
// Version information
//
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.11812.0112")]
=======================================
--- /Fizzler/Fizzler.csproj Wed Jun 3 13:26:53 2009
+++ /Fizzler/Fizzler.csproj Wed Nov 11 17:13:55 2009
@@ -46,6 +46,7 @@
<Compile Include="..\Common\SolutionInfo.cs">
<Link>SolutionInfo.cs</Link>
</Compile>
+ <Compile Include="SelectorsCachingCompiler.cs" />
<Compile Include="Either.cs" />
<Compile Include="IElementOps.cs" />
<Compile Include="ISelectorGenerator.cs" />
=======================================
--- /Fizzler/Properties/AssemblyInfo.cs Fri May 1 06:06:07 2009
+++ /Fizzler/Properties/AssemblyInfo.cs Wed Nov 11 17:13:55 2009
@@ -7,4 +7,4 @@
// Version information
//
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.11812.0112")]
=======================================
--- /NET-2.0/Fizzler.Systems.HtmlAgilityPack.csproj Wed Sep 30 23:20:04 2009
+++ /NET-2.0/Fizzler.Systems.HtmlAgilityPack.csproj Wed Nov 11 17:13:55 2009
@@ -37,14 +37,14 @@
<NoWarn>3001,3002,1685</NoWarn>
</PropertyGroup>
<ItemGroup>
- <Reference Include="BackLinq, Version=1.0.0.0, Culture=neutral,
processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\Libs\BackLinq.dll</HintPath>
- </Reference>
<Reference Include="HtmlAgilityPack, Version=1.3.0.0, Culture=neutral,
PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\HtmlAgilityPack.dll</HintPath>
</Reference>
+ <Reference Include="LinqBridge, Version=1.1.0.0, Culture=neutral,
PublicKeyToken=c2b14eb747628076, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Libs\LinqBridge.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.XML" />
=======================================
--- /NET-2.0/Fizzler.Tests.csproj Wed Sep 30 10:53:50 2009
+++ /NET-2.0/Fizzler.Tests.csproj Wed Nov 11 17:13:55 2009
@@ -32,14 +32,14 @@
<NoWarn>1685</NoWarn>
</PropertyGroup>
<ItemGroup>
- <Reference Include="BackLinq, Version=1.0.0.0, Culture=neutral,
processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\Libs\BackLinq.dll</HintPath>
- </Reference>
<Reference Include="HtmlAgilityPack, Version=1.3.0.0, Culture=neutral,
PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\HtmlAgilityPack.dll</HintPath>
</Reference>
+ <Reference Include="LinqBridge, Version=1.1.0.0, Culture=neutral,
PublicKeyToken=c2b14eb747628076, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Libs\LinqBridge.dll</HintPath>
+ </Reference>
<Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral,
PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\nunit.framework.dll</HintPath>
=======================================
--- /NET-2.0/Fizzler.csproj Sat Oct 31 12:13:41 2009
+++ /NET-2.0/Fizzler.csproj Wed Nov 11 17:13:55 2009
@@ -68,6 +68,9 @@
<Compile Include="..\Fizzler\SelectorGeneratorTee.cs">
<Link>SelectorGeneratorTee.cs</Link>
</Compile>
+ <Compile Include="..\Fizzler\SelectorsCachingCompiler.cs">
+ <Link>SelectorsCachingCompiler.cs</Link>
+ </Compile>
<Compile Include="..\Fizzler\Token.cs" />
<Compile Include="..\Fizzler\Tokener.cs" />
<Compile Include="..\Fizzler\TokenKind.cs" />
==============================================================================
Revision: 0193cd3fd75d
Branch: default
Author: azizatif
Date: Mon Feb 1 15:08:10 2010
Log: Fixed issue #38, "Visual Fizzler decodes HTML response
incorrectly."
http://code.google.com/p/fizzler/source/detail?r=0193cd3fd75d
Added:
/Libs/Mannex.dll
/Libs/Mannex.pdb
/Libs/Mannex.xml
Modified:
/VisualFizzler/MainForm.cs
/VisualFizzler/VisualFizzler.csproj
=======================================
--- /dev/null
+++ /Libs/Mannex.dll Mon Feb 1 15:08:10 2010
Binary file, no diff available.
=======================================
--- /dev/null
+++ /Libs/Mannex.pdb Mon Feb 1 15:08:10 2010
Binary file, no diff available.
=======================================
--- /dev/null
+++ /Libs/Mannex.xml Mon Feb 1 15:08:10 2010
@@ -0,0 +1,1151 @@
+<?xml version="1.0"?>
+<doc>
+ <assembly>
+ <name>Mannex</name>
+ </assembly>
+ <members>
+ <member name="T:Mannex.ArrayExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.Array"/> sub-types.
+ </summary>
+ </member>
+ <member name="M:Mannex.ArrayExtensions.ToHex(System.Byte[])">
+ <summary>
+ Formats bytes in hexadecimal format, appending to the
+ supplied <see cref="T:System.Text.StringBuilder"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.ArrayExtensions.ToHex(System.Byte[],System.Int32,System.Int32)">
+ <summary>
+ Formats bytes in hexadecimal format, appending to the
+ supplied <see cref="T:System.Text.StringBuilder"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.ArrayExtensions.ToHex(System.Byte[],System.Int32,System.Int32,System.Text.StringBuilder)">
+ <summary>
+ Formats bytes in hexadecimal format, appending to the
+ supplied <see cref="T:System.Text.StringBuilder"/>.
+ </summary>
+ </member>
+ <member name="T:Mannex.BooleanExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.Boolean"/>.
+ </summary>
+ </member>
+ <member
name="M:
Mannex.BooleanExtensions.To``1(System.Boolean,``0,``0)">
+ <summary>
+ Converts a <see cref="T:System.Boolean"/> to a value of type
<typeparamref name="T"/>
+ with a values for true and false states.
+ </summary>
+ </member>
+ <member name="T:Mannex.Collections.Generic.ListExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.Collections.Generic.List`1"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.LastIndex``1(System.Collections.Generic.IList{``0})">
+ <summary>
+ Returns the index of the last item in the list or -1 if the
+ list is empty.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.Push``1(System.Collections.Generic.IList{``0},``0)">
+ <summary>
+ Treats list like a stack, pushing <paramref name="value"/>
+ on to the list; in other words adding it to the end of
+ the list.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.Pop``1(System.Collections.Generic.IList{``0})">
+ <summary>
+ Treats list like a stack, popping (removing and returning)
+ the last value on the list.
+ </summary>
+ <exception cref="T:System.InvalidOperationException">
+ Thrown if list is empty.
+ </exception>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.TryPop``1(System.Collections.Generic.IList{``0})">
+ <summary>
+ Treats list like a stack, popping (removing and returning)
+ the last value on the list. If the list is empty, then
+ the default value for <typeparamref name="T"/> is returned.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.TryPop``1(System.Collections.Generic.IList{``0},``0)">
+ <summary>
+ Treats list like a stack, popping (removing and returning)
+ the last value on the list. If the list is empty, then
+ <paramref name="emptyValue"/> is returned instead.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.Peek``1(System.Collections.Generic.IList{``0})">
+ <summary>
+ Treats list like a stack, peeking and return the first
+ value on the list.
+ </summary>
+ <exception cref="T:System.InvalidOperationException">
+ Thrown if list is empty.
+ </exception>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.TryPeek``1(System.Collections.Generic.IList{``0})">
+ <summary>
+ Treats list like a stack, peeking and return the first
+ value on the list. If the list is empty, then
+ the default value for <typeparamref name="T"/> is returned.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.TryPeek``1(System.Collections.Generic.IList{``0},``0)">
+ <summary>
+ Treats list like a stack, peeking and return the first
+ value on the list. If the list is empty, then
+ <paramref name="emptyValue"/> is returned instead.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.Unshift``1(System.Collections.Generic.IList{``0},``0)">
+ <summary>
+ Adds <paramref name="value"/> to beginning of the list.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.Shift``1(System.Collections.Generic.IList{``0})">
+ <summary>
+ Removes and returns the first value of the list.
+ </summary>
+ <exception cref="T:System.InvalidOperationException">
+ Thrown if list is empty.
+ </exception>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.TryShift``1(System.Collections.Generic.IList{``0})">
+ <summary>
+ Removes and returns the first value of the list, returning
+ the default value for <typeparamref name="T"/> if the
+ list is empty.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.TryShift``1(System.Collections.Generic.IList{``0},``0)">
+ <summary>
+ Removes and returns the first value of the list, returning
+ <paramref name="emptyValue"/> if the list is empty.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.Enqueue``1(System.Collections.Generic.IList{``0},``0)">
+ <summary>
+ Treats list like a queue, appending <paramref name="value"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.Dequeue``1(System.Collections.Generic.IList{``0})">
+ <summary>
+ Treats list like a queue, removing and returning the
+ first value.
+ </summary>
+ <exception cref="T:System.InvalidOperationException">
+ Thrown if list is empty.
+ </exception>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.TryDequeue``1(System.Collections.Generic.IList{``0})">
+ <summary>
+ Treats list like a queue, removing and returning the
+ first value or the default value for <typeparamref name="T"/>
+ if the list is empty.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.TryDequeue``1(System.Collections.Generic.IList{``0},``0)">
+ <summary>
+ Treats list like a queue, removing and returning the
+ first value or <paramref name="emptyValue"/> if the
+ list is empty.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.Slice``1(System.Collections.Generic.IList{``0},System.Int32)">
+ <summary>
+ Returns elements from the list, starting at the index
+ specified by <paramref name="start"/> index.
+ </summary>
+ <remarks>
+ <para>
+ If <paramref name="start"/> is negative, it is treated as
+ <see cref="P:System.Collections.Generic.List`1.Count"/> +
<paramref name="start"/>.</para>
+ <para>
+ This method uses defered semantics.</para>
+ </remarks>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.ListExtensions.Slice``1(System.Collections.Generic.IList{``0},System.Int32,System.Int32)">
+ <summary>
+ Returns elements from the specified portion of the list,
+ identified by <paramref name="start"/> index and
+ <paramref name="end"/> (exclusive) index.
+ </summary>
+ <remarks>
+ <para>
+ This method copies up to, but not including, the element
indicated by
+ <paramref name="end"/>. If <paramref name="start"/> is
negative, it
+ is treated as <see
cref="P:System.Collections.Generic.List`1.Count"/> + <paramref
name="start"/>.
+ If <paramref name="end"/> is negative, it is treated as
+ <see cref="P:System.Collections.Generic.List`1.Count"/> +
<paramref name="end"/>.
+ If <paramref name="end"/> occurs before <paramref
name="start"/>, no
+ elements returned.</para>
+ <para>
+ This method uses defered semantics.</para>
+ </remarks>
+ </member>
+ <member name="T:Mannex.Collections.Generic.DictionaryExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.Collections.Generic.Dictionary`2"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.DictionaryExtensions.Find``2(System.Collections.Generic.IDictionary{``0,``1},``0)">
+ <summary>
+ Finds the value for a key, returning the default value for
+ <typeparamref name="TKey"/> if the key is not present.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.DictionaryExtensions.Find``2(System.Collections.Generic.IDictionary{``0,``1},``0,``1)">
+ <summary>
+ Finds the value for a key, returning a given default value for
+ <typeparamref name="TKey"/> if the key is not present.
+ </summary>
+ </member>
+ <member
name="T:Mannex.ComponentModel.Design.IServiceContainerExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.ComponentModel.Design.IServiceContainer"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.ComponentModel.Design.IServiceContainerExtensions.AddService``1(System.ComponentModel.Design.IServiceContainer,``0)">
+ <summary>
+ Adds the specified service to the service container.
+ </summary>
+ </member>
+ <member
name="T:Mannex.ComponentModel.INotifyPropertyChangedExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.ComponentModel.INotifyPropertyChanged"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.ComponentModel.INotifyPropertyChangedExtensions.OnPropertyChanged``2(``0,System.Linq.Expressions.Expression{System.Func{``0,``1}},System.ComponentModel.PropertyChangedEventHandler)">
+ <summary>
+ Subscribes to <see
cref="E:System.ComponentModel.INotifyPropertyChanged.PropertyChanged"/>
+ event of the soure object and calls <paramref name="handler"/>
only
+ when the property identified by <paramref name="expression"/>
+ has changed.
+ </summary>
+ <returns>
+ Returns the <see
cref="T:System.ComponentModel.PropertyChangedEventHandler"/> object that
+ can be used for unsubscribing.
+ </returns>
+ <exception cref="T:System.ArgumentException">
+ Thrown if <paramref name="expression"/> does not represent a
simple
+ property/field access type of expression (see <see
cref="T:System.Linq.Expressions.MemberExpression"/>).
+ </exception>
+ <remarks>
+ If <paramref name="expression"/> is <c>null</c> or empty then
+ <paramref name="handler"/> is called when any property changes.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.ComponentModel.INotifyPropertyChangedExtensions.OnPropertyChanged(System.ComponentModel.INotifyPropertyChanged,System.String,System.ComponentModel.PropertyChangedEventHandler)">
+ <summary>
+ Subscribes to <see
cref="E:System.ComponentModel.INotifyPropertyChanged.PropertyChanged"/>
+ event of the soure object and calls <paramref name="handler"/>
only
+ when the property identified by <paramref name="propertyName"/>
+ (case-insensitive) has changed.
+ </summary>
+ <returns>
+ Returns the <see
cref="T:System.ComponentModel.PropertyChangedEventHandler"/> object that
+ can be used for unsubscribing.
+ </returns>
+ <remarks>
+ If <paramref name="propertyName"/> is <c>null</c> or empty then
+ <paramref name="handler"/> is called when any property changes.
+ </remarks>
+ </member>
+ <member name="T:Mannex.Collections.Generic.IComparerExtensions">
+ <summary>
+ Extension methods for types implementing <see
cref="T:System.IComparable`1"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Collections.Generic.IComparerExtensions.Invert``1(System.Collections.Generic.IComparer{``0})">
+ <summary>
+ Creates an <see
cref="T:System.Collections.Generic.IComparer`1"/> implementation
+ that inverts the results of comparing values through
+ another comparer such that the sort order is inverted.
+ </summary>
+ </member>
+ <member name="T:Mannex.Data.IDataReaderExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.Data.IDataReader"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Data.IDataReaderExtensions.Select``1(System.Data.IDataReader,System.Func{System.Data.IDataRecord,``0})">
+ <summary>
+ Projects each record of the reader into a new form.
+ </summary>
+ </member>
+ <member name="T:Mannex.DateTimeExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.DateTime"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.DateTimeExtensions.ToUnixTime(System.DateTime)">
+ <summary>
+ Returns number of milliseconds (including fractions) in UTC
between the
+ specified date and midnight January 1, 1970.
+ </summary>
+ </member>
+ <member
name="M:Mannex.DateTimeExtensions.TrimToSecond(System.DateTime)">
+ <summary>
+ Trims millisecond component so that the precision of the
+ resulting time is to the second.
+ </summary>
+ </member>
+ <member
name="M:Mannex.DateTimeExtensions.TrimToMinute(System.DateTime)">
+ <summary>
+ Trims the second and millisecond components so that the
+ precision of the resulting time is to the minute.
+ </summary>
+ </member>
+ <member
name="M:Mannex.DateTimeExtensions.TrimToHour(System.DateTime)">
+ <summary>
+ Trims the minute, second and millisecond components so that the
+ precision of the resulting time is to the hour.
+ </summary>
+ </member>
+ <member
name="M:Mannex.DateTimeExtensions.TrimToDay(System.DateTime)">
+ <summary>
+ Trims the time components so that the precision of the
resulting
+ time is to the day.
+ </summary>
+ </member>
+ <member
name="M:Mannex.DateTimeExtensions.IsMidnight(System.DateTime)">
+ <summary>
+ Determines if the time component is midnight exactly.
+ </summary>
+ </member>
+ <member name="T:Mannex.Diagnostics.ProcessExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.Diagnostics.Process"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Diagnostics.ProcessExtensions.TryKill(System.Diagnostics.Process)">
+ <summary>
+ Attempts to kill the process identified by the <see
cref="T:System.Diagnostics.Process"/>
+ object and returns <c>null</c> on success otherwise the error
+ that occurred in the attempt.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Diagnostics.ProcessExtensions.WaitForExit(System.Diagnostics.Process,System.Nullable{System.TimeSpan})">
+ <summary>
+ Instructs the <see cref="T:System.Diagnostics.Process"/>
component to wait the specified
+ amount of time for the associated process to exit. If the
specified
+ time-out period is <c>null</c> then the wait is indefinite.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Diagnostics.ProcessExtensions.BeginReadLine(System.Diagnostics.Process,System.IO.TextWriter)">
+ <summary>
+ Begins asynchronous read operations on the re-directed <see
cref="P:System.Diagnostics.Process.StandardOutput"/>
+ and <see cref="P:System.Diagnostics.Process.StandardError"/>
of the application.
+ Each line on the standard output is written to a <see
cref="T:System.IO.TextWriter"/>.
+ </summary>
+ <returns>
+ Returns an action that can be used to wait on outputs to drain.
+ </returns>
+ </member>
+ <member
name="M:Mannex.Diagnostics.ProcessExtensions.BeginReadLine(System.Diagnostics.Process,System.IO.TextWriter,System.IO.TextWriter)">
+ <summary>
+ Begins asynchronous read operations on the re-directed <see
cref="P:System.Diagnostics.Process.StandardOutput"/>
+ and <see cref="P:System.Diagnostics.Process.StandardError"/>
of the application.
+ Each line on either is written to a respective <see
cref="T:System.IO.TextWriter"/>.
+ </summary>
+ <returns>
+ Returns an action that can be used to wait on outputs to drain.
+ </returns>
+ </member>
+ <member
name="M:Mannex.Diagnostics.ProcessExtensions.BeginReadLine(System.Diagnostics.Process,System.Action{System.String})">
+ <summary>
+ Begins asynchronous read operations on the re-directed <see
cref="P:System.Diagnostics.Process.StandardOutput"/>
+ and <see cref="P:System.Diagnostics.Process.StandardError"/>
of the application. Each line on the standard output
+ is sent to a callback.
+ </summary>
+ <returns>
+ Returns an action that can be used to wait on outputs to drain.
+ </returns>
+ </member>
+ <member
name="M:Mannex.Diagnostics.ProcessExtensions.BeginReadLine(System.Diagnostics.Process,System.Action{System.String},System.Action{System.String})">
+ <summary>
+ Begins asynchronous read operations on the re-directed <see
cref="P:System.Diagnostics.Process.StandardOutput"/>
+ and <see cref="P:System.Diagnostics.Process.StandardError"/>
of the application. Each line on either is
+ sent to a respective callback.
+ </summary>
+ <returns>
+ Returns an action that can be used to wait on outputs to drain.
+ </returns>
+ </member>
+ <member name="T:Mannex.IO.ArrayExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.Array"/> sub-types.
+ </summary>
+ </member>
+ <member name="M:Mannex.IO.ArrayExtensions.OpenRead(System.Byte[])">
+ <summary>
+ Creates a read-only stream on top of the supplied byte array.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.ArrayExtensions.OpenRead(System.Byte[],System.Int32,System.Int32)">
+ <summary>
+ Creates a read-only stream on top of a section of supplied
+ byte array.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.ArrayExtensions.OpenReadWrite(System.Byte[])">
+ <summary>
+ Creates a read-write stream on top of the supplied byte array.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.ArrayExtensions.OpenReadWrite(System.Byte[],System.Int32,System.Int32)">
+ <summary>
+ Creates a read-write stream on top of a section of supplied
+ byte array.
+ </summary>
+ </member>
+ <member name="T:Mannex.IO.ArraySegmentExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.ArraySegment`1"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.ArraySegmentExtensions.OpenRead(System.ArraySegment{System.Byte})">
+ <summary>
+ Creates a read-only stream on top of the supplied buffer.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.ArraySegmentExtensions.OpenReadWrite(System.ArraySegment{System.Byte})">
+ <summary>
+ Creates a read-write stream on top of the supplied buffer.
+ </summary>
+ </member>
+ <member name="T:Mannex.IO.StreamExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.IO.Stream"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StreamExtensions.Copy(System.IO.Stream,System.IO.Stream)">
+ <summary>
+ Copies one stream into another using a transfer buffer size of
4K.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StreamExtensions.Copy(System.IO.Stream,System.IO.Stream,System.Int32)">
+ <summary>
+ Copies one stream into another using a caller-specified
transfer
+ buffer size.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StreamExtensions.Copy(System.IO.Stream,System.IO.Stream,System.Byte[])">
+ <summary>
+ Copies one stream into another using a caller-specified
transfer
+ buffer. If the buffer is null then a default one of 4K is used.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StreamExtensions.SaveTo(System.IO.Stream,System.Byte[])">
+ <summary>
+ Copies content of the stream to fill the given buffer.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StreamExtensions.SaveTo(System.IO.Stream,System.Byte[],System.Int32,System.Int32)">
+ <summary>
+ Copies content of the stream to fill the given buffer.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StreamExtensions.SaveToFile(System.IO.Stream,System.String)">
+ <summary>
+ Saves the content of the input stream from its current position
+ to the given file path using a default transfer buffer size of
+ 4K.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StreamExtensions.SaveToFile(System.IO.Stream,System.String,System.Int32)">
+ <summary>
+ Saves the content of the input stream from its current position
+ to the given file path using a caller-specified transfer
+ buffer size.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StreamExtensions.Memorize(System.IO.Stream)">
+ <summary>
+ Copies the content of the input stream from its current
position
+ to a memory-based stream.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StreamExtensions.ToArray(System.IO.Stream)">
+ <summary>
+ Returns the remaining contents of the input as an array of
+ unsigned bytes.
+ </summary>
+ </member>
+ <member name="T:Mannex.IO.StringExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.String"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.StringExtensions.ToFileNameSafe(System.String)">
+ <summary>
+ Makes the content of the string safe for use as a file name
+ by replacing all invalid characters, those returned by
+ <see cref="M:System.IO.Path.GetInvalidFileNameChars"/>, with
an underscore.
+ </summary>
+ <remarks>
+ This method is not guaranteed to replace the complete set of
+ characters that are invalid in file and directory names.
+ The full set of invalid characters can vary by file system.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.IO.StringExtensions.ToFileNameSafe(System.String,System.String)">
+ <summary>
+ Makes the content of the string safe for use as a file name
+ by replacing all invalid characters, those returned by
+ <see cref="M:System.IO.Path.GetInvalidFileNameChars"/>, with
+ <paramref name="replacement"/>.
+ </summary>
+ <remarks>
+ <para>
+ The <paramref name="replacement"/> string itself cannot
+ carry any invalid file name characters. If
+ <paramref name="replacement"/> is <c>null</c> or empty
+ then it assumes the value of an underscore.</para>
+ <para>
+ This method is not guaranteed to replace the complete set of
+ characters that are invalid in file and directory names.
+ The full set of invalid characters can vary by file system.
+ </para>
+ </remarks>
+ </member>
+ <member
name="M:Mannex.IO.StringExtensions.ToPathNameSafe(System.String)">
+ <summary>
+ Makes the content of the string safe for use as a file name
+ by replacing all invalid characters, those returned by
+ <see cref="M:System.IO.Path.GetInvalidPathChars"/>, with an
underscore.
+ </summary>
+ <remarks>
+ This method is not guaranteed to replace the complete set of
+ characters that are invalid in file and directory names.
+ The full set of invalid characters can vary by file system.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.IO.StringExtensions.ToPathNameSafe(System.String,System.String)">
+ <summary>
+ Makes the content of the string safe for use as a file name
+ by replacing all invalid characters, those returned by
+ <see cref="M:System.IO.Path.GetInvalidPathChars"/>, with
+ <paramref name="replacement"/>.
+ </summary>
+ <remarks>
+ The <paramref name="replacement"/> string itself cannot
+ carry any invalid file name characters. If
+ <paramref name="replacement"/> is <c>null</c> or empty
+ then it assumes the value of an underscore.
+ <para>
+ This method is not guaranteed to replace the complete set of
+ characters that are invalid in file and directory names.
+ The full set of invalid characters can vary by file system.
+ </para>
+ </remarks>
+ </member>
+ <member name="M:Mannex.IO.StringExtensions.Read(System.String)">
+ <summary>
+ Returns a <see cref="T:System.IO.TextReader"/> for reading
string.
+ </summary>
+ </member>
+ <member name="T:Mannex.IO.TextReaderExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.IO.TextReader"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.IO.TextReaderExtensions.ReadLines(System.IO.TextReader)">
+ <summary>
+ Reads all lines from reader using deferred semantics.
+ </summary>
+ </member>
+ <member name="T:Mannex.Json.NameValueCollectionExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.Collections.Specialized.NameValueCollection"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Json.NameValueCollectionExtensions.ToJsonString(System.Collections.Specialized.NameValueCollection)">
+ <summary>
+ Formats collection as JSON text.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Json.NameValueCollectionExtensions.WriteJsonStringTo(System.Collections.Specialized.NameValueCollection,System.IO.TextWriter)">
+ <summary>
+ Formats collection as JSON text, sending output to <paramref
name="writer"/>.
+ </summary>
+ </member>
+ <member name="T:Mannex.Json.StringExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.String"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Json.StringExtensions.ToJsonString(System.String)">
+ <summary>
+ Formats string as JSON text string.
+ </summary>
+ <remarks>
+ String may be <c>null</c>, in which case <c>"null"</c> is
+ returned.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.Json.StringExtensions.WriteJsonStringTo(System.String,System.IO.TextWriter)">
+ <summary>
+ Formats string as JSON text string, sending output to
+ <paramref name="writer"/>.
+ </summary>
+ <remarks>
+ String may be <c>null</c>, in which case <c>"null"</c> is
+ returned.
+ </remarks>
+ </member>
+ <member name="T:Mannex.Net.Mime.ContentTypeExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.Net.Mime.ContentType"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Net.Mime.ContentTypeExtensions.IsPlainText(System.Net.Mime.ContentType)">
+ <summary>
+ Determines whether content type is plain text.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Net.Mime.ContentTypeExtensions.IsText(System.Net.Mime.ContentType)">
+ <summary>
+ Determines whether content media type is text.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Net.Mime.ContentTypeExtensions.IsHtml(System.Net.Mime.ContentType)">
+ <summary>
+ Determines whether content type identifies an HTML document.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Net.Mime.ContentTypeExtensions.IsImage(System.Net.Mime.ContentType)">
+ <summary>
+ Determines whether content media type identifies an image.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Net.Mime.ContentTypeExtensions.GetMediaBaseType(System.Net.Mime.ContentType)">
+ <summary>
+ Gets the base media of the content type, e.g. text from
text/plain.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Net.Mime.ContentTypeExtensions.GetMediaSubType(System.Net.Mime.ContentType)">
+ <summary>
+ Gets the media sub-type of the content type, e.g. plain from
text/plain.
+ </summary>
+ </member>
+ <member name="T:Mannex.Net.WebClientExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.Net.WebClient"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Net.WebClientExtensions.GetResponseContentType(System.Net.WebClient)">
+ <summary>
+ Gets the values of the HTTP
+ <a
href="
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">Content-Type</a>
+ response header as an instance of the <see
cref="T:System.Net.Mime.ContentType"/> object.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Net.WebClientExtensions.DownloadStringUsingResponseEncoding(System.Net.WebClient,System.String)">
+ <summary>
+ Same as <see
cref="M:System.Net.WebClient.DownloadString(System.String)"/> except it
+ correctly use the character set indicated in the response to
decode
+ the string. Otherwise it uses <see
cref="P:System.Net.WebClient.Encoding"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Net.WebClientExtensions.DownloadStringUsingResponseEncoding(System.Net.WebClient,System.Uri)">
+ <summary>
+ Same as <see
cref="M:System.Net.WebClient.DownloadString(System.Uri)"/> except it
+ correctly use the character set indicated in the response to
decode
+ the string. Otherwise it uses <see
cref="P:System.Net.WebClient.Encoding"/>.
+ </summary>
+ </member>
+ <member name="T:Mannex.Reflection.AssemblyExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.Reflection.Assembly"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Reflection.AssemblyExtensions.GetManifestResourceReader(System.Reflection.Assembly,System.Type,System.String)">
+ <summary>
+ Loads the specified manifest resource, scoped by the namespace
+ of the specified type, from this assembly and returns
+ it ready for reading as <see cref="T:System.IO.TextReader"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Reflection.AssemblyExtensions.GetManifestResourceReader(System.Reflection.Assembly,System.Type,System.String,System.Text.Encoding)">
+ <summary>
+ Loads the specified manifest resource, scoped by the namespace
+ of the specified type, from this assembly and returns
+ it ready for reading as <see cref="T:System.IO.TextReader"/>.
A parameter
+ specifies the text encoding to be used for reading.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Reflection.AssemblyExtensions.GetManifestResourceString(System.Reflection.Assembly,System.Type,System.String)">
+ <summary>
+ Loads the specified manifest resource and returns it as a
string,
+ scoped by the namespace of the specified type, from this
assembly.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Reflection.AssemblyExtensions.GetManifestResourceString(System.Reflection.Assembly,System.Type,System.String,System.Text.Encoding)">
+ <summary>
+ Loads the specified manifest resource and returns it as a
string,
+ scoped by the namespace of the specified type, from this
assembly.
+ A parameter specifies the text encoding to be decode the
resource
+ bytes into text.
+ </summary>
+ </member>
+ <member
name="T:Mannex.Reflection.ICustomAttributeProviderExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.Reflection.ICustomAttributeProvider"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Reflection.ICustomAttributeProviderExtensions.IsDefined``1(System.Reflection.ICustomAttributeProvider,System.Boolean)">
+ <summary>
+ Indicates whether one or more instance of <typeparamref
name="T"/>
+ is defined on this member.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Reflection.ICustomAttributeProviderExtensions.GetCustomAttributes``1(System.Reflection.ICustomAttributeProvider,System.Boolean)">
+ <summary>
+ Returns <typeparamref name="T"/> custom attributes defined on
+ this member.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Reflection.ICustomAttributeProviderExtensions.GetCustomAttribute``1(System.Reflection.ICustomAttributeProvider,System.Boolean)">
+ <summary>
+ Returns a specific custom attribute defined on this member.
+ </summary>
+ </member>
+ <member name="T:Mannex.StringExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.String"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.StringExtensions.MaskEmpty(System.String,System.String)">
+ <summary>
+ Masks an empty string with a given mask such that the result
+ is never an empty string. If the input string is null or
+ empty then it is masked, otherwise the original is returned.
+ </summary>
+ <remarks>
+ Use this method to guarantee that you never get an empty
+ string. Bear in mind, however, that if the mask itself is an
+ empty string then this method could yield an empty string!
+ </remarks>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Slice(System.String,System.Int32)">
+ <summary>
+ Returns a section of a string from a give starting point on.
+ </summary>
+ <remarks>
+ If <paramref name="start"/> is negative, it is treated as
+ <c>length</c> + <paramref name="start" /> where <c>length</c>
+ is the length of the string. If <paramref name="start"/>
+ is greater or equal to the length of the string then
+ no characters are copied to the new string.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Slice(System.String,System.Int32,System.Nullable{System.Int32})">
+ <summary>
+ Returns a section of a string.
+ </summary>
+ <remarks>
+ This method copies up to, but not including, the element
+ indicated by <paramref name="end"/>. If <paramref
name="start"/>
+ is negative, it is treated as <c>length</c> + <paramref
name="start" />
+ where <c>length</c> is the length of the string. If
+ <paramref name="end"/> is negative, it is treated as
<c>length</c> +
+ <paramref name="end"/> where <c>length</c> is the length of the
+ string. If <paramref name="end"/> occurs before <paramref
name="start"/>,
+ no characters are copied to the new string.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Embed(System.String,System.String)">
+ <summary>
+ Embeds string into <paramref name="target"/>, using {0}
+ within <paramref name="target"/> as the point of embedding.
+ </summary>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Wrap(System.String,System.String,System.String)">
+ <summary>
+ Wraps string between two other string where the first
+ indicates the left side and the second indicates the
+ right side.
+ </summary>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Quote(System.String,System.String,System.String)">
+ <summary>
+ Enquotes string with <paramref name="quote"/>, escaping
occurences
+ of <paramref name="quote"/> itself with <paramref
name="escape"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.StringExtensions.FormatWith(System.String,System.Func{System.String,System.Object[],System.IFormatProvider,System.String},System.Object[])">
+ <summary>
+ Format string using <paramref name="args"/> as sources for
+ replacements and a function, <paramref name="binder"/>, that
+ determines how to bind and resolve replacement tokens.
+ </summary>
+ </member>
+ <member
name="M:Mannex.StringExtensions.FormatWith(System.String,System.IFormatProvider,System.Func{System.String,System.Object[],System.IFormatProvider,System.String},System.Object[])">
+ <summary>
+ Format string using <paramref name="args"/> as sources for
+ replacements and a function, <paramref name="binder"/>, that
+ determines how to bind and resolve replacement tokens. In
+ addition, <paramref name="provider"/> is used for cultural
+ formatting.
+ </summary>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Split``1(System.String,System.Char,System.Func{System.String,System.String,``0})">
+ <summary>
+ Splits a string into a pair using a specified character to
+ separate the two.
+ </summary>
+ <remarks>
+ Neither half in the resulting pair is ever <c>null</c>.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Split``1(System.String,System.Char,System.Func{System.String,System.String,System.String,``0})">
+ <summary>
+ Splits a string into three parts using any of a specified set
of
+ characters to separate the three.
+ </summary>
+ <remarks>
+ None of the resulting parts is ever <c>null</c>.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Split``1(System.String,System.Char,System.Func{System.String,System.String,System.String,System.String,``0})">
+ <summary>
+ Splits a string into four parts using any of a specified set of
+ characters to separate the four.
+ </summary>
+ <remarks>
+ None of the resulting parts is ever <c>null</c>.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Split``1(System.String,System.Char[],System.Func{System.String,System.String,``0})">
+ <summary>
+ Splits a string into a pair using any of a specified set of
+ characters to separate the two.
+ </summary>
+ <remarks>
+ Neither half in the resulting pair is ever <c>null</c>.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Split``1(System.String,System.Char[],System.Func{System.String,System.String,System.String,``0})">
+ <summary>
+ Splits a string into three parts using any of a specified set
of
+ characters to separate the three.
+ </summary>
+ <remarks>
+ None of the resulting parts is ever <c>null</c>.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.StringExtensions.Split``1(System.String,System.Char[],System.Func{System.String,System.String,System.String,System.String,``0})">
+ <summary>
+ Splits a string into four parts using any of a specified set of
+ characters to separate the four.
+ </summary>
+ <remarks>
+ None of the resulting parts is ever <c>null</c>.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.StringExtensions.SplitRemoving``1(System.String,System.Int32,System.Int32,System.Func{System.String,System.String,``0})">
+ <summary>
+ Splits a string into a pair by removing a portion of the
string.
+ </summary>
+ <remarks>
+ Neither half in the resulting pair is ever <c>null</c>.
+ </remarks>
+ </member>
+ <member name="T:Mannex.EventHandlerExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.EventHandler"/> and
+ <see cref="T:System.EventHandler`1"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.EventHandlerExtensions.Fire``1(System.EventHandler{``0},System.Object,``0)">
+ <summary>
+ Fires an event given its arguments.
+ </summary>
+ <returns>
+ Boolean value indicating whether the event was fired or not.
The
+ only event under which the event is not fired is there are no
+ handlers attached.
+ </returns>
+ </member>
+ <member name="T:Mannex.Int32Extensions">
+ <summary>
+ Extension methods for <see cref="T:System.Int32"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Int32Extensions.ToInvariantString(System.Int32)">
+ <summary>
+ Converts <see cref="T:System.Int32"/> to its string
representation in the
+ invariant culture.
+ </summary>
+ </member>
+ <member name="T:Mannex.PredicateExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.Predicate`1"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.PredicateExtensions.And``1(System.Predicate{``0},System.Predicate{``0})">
+ <summary>
+ Combines two <see cref="T:System.Predicate`1"/> to form a
logical AND.
+ </summary>
+ </member>
+ <member
name="M:Mannex.PredicateExtensions.Or``1(System.Predicate{``0},System.Predicate{``0})">
+ <summary>
+ Combines two <see cref="T:System.Predicate`1"/> to form a
logical OR.
+ </summary>
+ </member>
+ <member name="T:Mannex.Text.RegularExpressions.StringExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.String"/> that help
with regular
+ expression matching.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Text.RegularExpressions.StringExtensions.IsMatch(System.String,System.String)">
+ <summary>
+ Indicates whether the string contains a match for the regular
+ expression pattern specified as an argument.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Text.RegularExpressions.StringExtensions.IsMatch(System.String,System.String,System.Text.RegularExpressions.RegexOptions)">
+ <summary>
+ Indicates whether the string contains a match for the regular
+ expression pattern specified as an argument along with
+ matching options.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Text.RegularExpressions.StringExtensions.Match(System.String,System.String)">
+ <summary>
+ Searches string for an occurrence of the regular expression
+ specified as an argument.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Text.RegularExpressions.StringExtensions.Match(System.String,System.String,System.Text.RegularExpressions.RegexOptions)">
+ <summary>
+ Searches string for an occurrence of the regular expression
+ specified as an argument along with matching options.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Text.RegularExpressions.StringExtensions.Matches(System.String,System.String)">
+ <summary>
+ Searches the specified input string for all occurrences of the
+ regular expression specified as an argument.
+ </summary>
+ <remarks>
+ This method uses deferred execution semantics.
+ </remarks>
+ </member>
+ <member
name="M:Mannex.Text.RegularExpressions.StringExtensions.Matches(System.String,System.String,System.Text.RegularExpressions.RegexOptions)">
+ <summary>
+ Searches the specified input string for all occurrences of the
+ regular expression specified as an argument along with matching
+ options.
+ </summary>
+ <remarks>
+ This method uses deferred execution semantics.
+ </remarks>
+ </member>
+ <member name="T:Mannex.Threading.TimeSpanExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.TimeSpan"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Threading.TimeSpanExtensions.ToTimeout(System.TimeSpan)">
+ <summary>
+ Converts <see cref="T:System.TimeSpan"/> to milliseconds as
expected by
+ most of the <see cref="N:System.Threading"/> API.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Threading.TimeSpanExtensions.ToTimeout(System.Nullable{System.TimeSpan})">
+ <summary>
+ Converts <see cref="T:System.TimeSpan"/> to milliseconds as
expected by
+ most of the <see cref="N:System.Threading"/> API. If the the
+ <see cref="T:System.TimeSpan"/> value is <c>null</c> then the
result is
+ same as <see cref="F:System.Threading.Timeout.Infinite"/>.
+ </summary>
+ </member>
+ <member name="T:Mannex.Web.HtmlStringExtensions">
+ <summary>
+ HTML utility methods for <see cref="T:System.String"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Web.HtmlStringExtensions.HtmlEncode(System.String)">
+ <summary>
+ Converts a string into an HTML-encoded string.
+ </summary>
+ </member>
+ <member name="T:Mannex.Web.NameValueCollectionExtensions">
+ <summary>
+ Extension methods for <see
cref="T:System.Collections.Specialized.NameValueCollection"/>.
+ </summary>
+ </member>
+ <member
name="M:Mannex.Web.NameValueCollectionExtensions.ToQueryString(System.Collections.Specialized.NameValueCollection)">
+ <summary>
+ Creates a query string from the key and value pairs found
+ in the collection.
+ </summary>
+ <remarks>
+ A question mark (?) is prepended if the resulting query string
+ is not empty.
+ </remarks>
+ </member>
+ <member name="T:Mannex.Web.UriExtensions">
+ <summary>
+ Extension methods for <see cref="T:System.Uri"/>.
***The diff for this file has been truncated for email.***
=======================================
--- /VisualFizzler/MainForm.cs Wed Sep 30 23:20:04 2009
+++ /VisualFizzler/MainForm.cs Mon Feb 1 15:08:10 2010
@@ -11,6 +11,7 @@
using Fizzler;
using Fizzler.Systems.HtmlAgilityPack;
using HtmlAgilityPack;
+using Mannex.Net;
using Microsoft.VisualBasic;
using HtmlDocument=HtmlAgilityPack.HtmlDocument;
@@ -119,7 +120,7 @@
try
{
using (CurrentCursorScope.EnterWait())
- content = wc.DownloadString(url);
+ content = wc.DownloadStringUsingResponseEncoding(url);
}
catch (WebException e)
{
=======================================
--- /VisualFizzler/VisualFizzler.csproj Fri May 1 08:07:53 2009
+++ /VisualFizzler/VisualFizzler.csproj Mon Feb 1 15:08:10 2010
@@ -35,6 +35,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\HtmlAgilityPack.dll</HintPath>
</Reference>
+ <Reference Include="Mannex, Version=1.0.12026.0, Culture=neutral,
processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Libs\Mannex.dll</HintPath>
+ </Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" />
<Reference Include="System.Core">
==============================================================================
Revision: 831c4696e90a
Branch: default
Author: azizatif
Date: Tue Feb 2 14:12:36 2010
Log: Fixed license region in SolutionInfo.cs.
http://code.google.com/p/fizzler/source/detail?r=831c4696e90a
Modified:
/Common/SolutionInfo.cs
=======================================
--- /Common/SolutionInfo.cs Fri May 1 06:06:07 2009
+++ /Common/SolutionInfo.cs Tue Feb 2 14:12:36 2010
@@ -1,12 +1,11 @@
#region License, Terms and Conditions
//
-// Jayrock - JSON and JSON-RPC for Microsoft .NET Framework and Mono
-// Written by Atif Aziz (
www.raboof.com)
-// Copyright (c) 2005 Atif Aziz. All rights reserved.
+// Fizzler - CSS Selector Engine for Microsoft .NET Framework and Mono
+// Copyright (c) 2009, 2010 Atif Aziz, Colin Ramsay. All rights reserved.
//
// This library is free software; you can redistribute it and/or modify it
under
// the terms of the GNU Lesser General Public License as published by the
Free
-// Software Foundation; either version 2.1 of the License, or (at your
option)
+// Software Foundation; either version 3 of the License, or (at your
option)
// any later version.
//
// This library is distributed in the hope that it will be useful, but
WITHOUT
@@ -34,7 +33,7 @@
[assembly: AssemblyProduct("Fizzler")]
[assembly: AssemblyCompany("
http://fizzler.googlecode.com")]
-[assembly: AssemblyCopyright("Copyright (c) 2009, Atif Aziz, Colin Ramsay.
All rights reserved.")]
+[assembly: AssemblyCopyright("Copyright (c) 2009, 2010 Atif Aziz, Colin
Ramsay. All rights reserved.")]
[assembly: AssemblyCulture("")]
//
==============================================================================
Revision: 8eb741921502
Branch: default
Author: azizatif
Date: Tue Feb 2 14:28:39 2010
Log: Moved imports inside namespace declarations.
http://code.google.com/p/fizzler/source/detail?r=8eb741921502
Modified:
/ConsoleFizzler/Command.cs
/ConsoleFizzler/CommandLine.cs
/ConsoleFizzler/ExplainCommand.cs
/ConsoleFizzler/NameValueCollectionExtensions.cs
/ConsoleFizzler/Program.cs
/ConsoleFizzler/SelectCommand.cs
/ConsoleFizzler/StringExtensions.cs
/Fizzler.Sandbox/WinForms/ControlExtensions.cs
/Fizzler.Sandbox/WinForms/ControlOps.cs
/Fizzler.Sandbox/WinForms/ControlSelection.cs
/Fizzler.Sandbox/Xml/XmlNodeExtensions.cs
/Fizzler.Sandbox/Xml/XmlNodeOps.cs
/Fizzler.Sandbox/Xml/XmlNodeSelection.cs
/Fizzler.Systems.HtmlAgilityPack/HtmlDocumentExtensions.cs
/Fizzler.Systems.HtmlAgilityPack/HtmlNodeExtensions.cs
/Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs
/Fizzler.Systems.HtmlAgilityPack/HtmlNodeSelection.cs
/Fizzler.Tests/AttributeSelectors.cs
/Fizzler.Tests/ChildAndAdjacentSelectors.cs
/Fizzler.Tests/ClassSelector.cs
/Fizzler.Tests/ElementSelector.cs
/Fizzler.Tests/HumanReadableSelectorGeneratorTests.cs
/Fizzler.Tests/IDSelector.cs
/Fizzler.Tests/MultipleSelectors.cs
/Fizzler.Tests/NamespacePrefixTests.cs
/Fizzler.Tests/NthChild.cs
/Fizzler.Tests/ParserTests.cs
/Fizzler.Tests/PsuedoSelectors.cs
/Fizzler.Tests/ReaderTests.cs
/Fizzler.Tests/SelectorBaseTest.cs
/Fizzler.Tests/SelectorGeneratorTeeTests.cs
/Fizzler.Tests/TokenTests.cs
/Fizzler.Tests/TokenerTests.cs
/Fizzler/Either.cs
/Fizzler/HumanReadableSelectorGenerator.cs
/Fizzler/NamespacePrefix.cs
/Fizzler/Parser.cs
/Fizzler/Reader.cs
/Fizzler/Selector.cs
/Fizzler/SelectorGenerator.cs
/Fizzler/SelectorGeneratorTee.cs
/Fizzler/SelectorsCachingCompiler.cs
/Fizzler/Token.cs
/Fizzler/Tokener.cs
=======================================
--- /ConsoleFizzler/Command.cs Thu Apr 30 10:50:13 2009
+++ /ConsoleFizzler/Command.cs Tue Feb 2 14:28:39 2010
@@ -1,8 +1,8 @@
-using System;
-using System.Configuration;
-
namespace ConsoleFizzler
{
+ using System;
+ using System.Configuration;
+
internal abstract class Command : ICommand
{
public int Run(string[] args)
=======================================
--- /ConsoleFizzler/CommandLine.cs Mon May 11 12:59:40 2009
+++ /ConsoleFizzler/CommandLine.cs Tue Feb 2 14:28:39 2010
@@ -1,13 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.ComponentModel;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices;
+namespace ConsoleFizzler
+{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.IO;
+ using System.Linq;
+ using System.Runtime.InteropServices;
+
+ #endregion
-namespace ConsoleFizzler
-{
static class CommandLine
{
private static readonly char[] _argSeparators = new[] { ':', '=' };
=======================================
--- /ConsoleFizzler/ExplainCommand.cs Thu Apr 30 10:50:13 2009
+++ /ConsoleFizzler/ExplainCommand.cs Tue Feb 2 14:28:39 2010
@@ -1,9 +1,13 @@
-using System;
-using System.Linq;
-using Fizzler;
-
namespace ConsoleFizzler
{
+ #region Imports
+
+ using System;
+ using System.Linq;
+ using Fizzler;
+
+ #endregion
+
internal sealed class ExplainCommand : Command
{
protected override int OnRun(string[] args)
=======================================
--- /ConsoleFizzler/NameValueCollectionExtensions.cs Thu Apr 30 10:50:13
2009
+++ /ConsoleFizzler/NameValueCollectionExtensions.cs Tue Feb 2 14:28:39
2010
@@ -1,10 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Linq;
-
-namespace ConsoleFizzler
+namespace ConsoleFizzler
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Collections.Specialized;
+ using System.Linq;
+
+ #endregion
+
static class NameValueCollectionExtensions
{
public static IEnumerable<string> KeysByPrefix(this
NameValueCollection collection, string prefix)
=======================================
--- /ConsoleFizzler/Program.cs Fri May 1 04:30:11 2009
+++ /ConsoleFizzler/Program.cs Tue Feb 2 14:28:39 2010
@@ -1,14 +1,18 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
+namespace ConsoleFizzler
+{
+ #region Imports
-using CommandNames = System.Collections.Generic.KeyValuePair<
- /* key */ System.Func<ConsoleFizzler.ICommand>,
- /* value */ System.Collections.Generic.IEnumerable<string>>;
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Linq;
+
+ using CommandNames = System.Collections.Generic.KeyValuePair<
+ /* key */ System.Func<ICommand>,
+ /* value */ System.Collections.Generic.IEnumerable<string>>;
+
+ #endregion
-namespace ConsoleFizzler
-{
internal static class Program
{
internal static int Main(string[] args)
=======================================
--- /ConsoleFizzler/SelectCommand.cs Wed Sep 30 23:20:04 2009
+++ /ConsoleFizzler/SelectCommand.cs Tue Feb 2 14:28:39 2010
@@ -1,12 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using Fizzler.Systems.HtmlAgilityPack;
-using HtmlAgilityPack;
-
namespace ConsoleFizzler
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Linq;
+ using Fizzler.Systems.HtmlAgilityPack;
+ using HtmlAgilityPack;
+
+ #endregion
+
internal sealed class SelectCommand : Command
{
private string _separator;
=======================================
--- /ConsoleFizzler/StringExtensions.cs Thu Apr 30 10:50:13 2009
+++ /ConsoleFizzler/StringExtensions.cs Tue Feb 2 14:28:39 2010
@@ -1,9 +1,13 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-
-namespace ConsoleFizzler
+namespace ConsoleFizzler
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Globalization;
+
+ #endregion
+
static class StringExtensions
{
/// <summary>
=======================================
--- /Fizzler.Sandbox/WinForms/ControlExtensions.cs Wed Apr 29 10:23:40 2009
+++ /Fizzler.Sandbox/WinForms/ControlExtensions.cs Tue Feb 2 14:28:39 2010
@@ -1,11 +1,15 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Windows.Forms;
-
-namespace Fizzler.Systems.WinForms
+namespace Fizzler.Systems.WinForms
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Diagnostics;
+ using System.Windows.Forms;
+
+ #endregion
+
/// <summary>
/// Extension methods for <see cref="Control"/>.
/// </summary>
=======================================
--- /Fizzler.Sandbox/WinForms/ControlOps.cs Tue Jun 2 06:47:04 2009
+++ /Fizzler.Sandbox/WinForms/ControlOps.cs Tue Feb 2 14:28:39 2010
@@ -1,9 +1,13 @@
-using System;
-using System.Linq;
-using System.Windows.Forms;
-
namespace Fizzler.Systems.WinForms
{
+ #region Imports
+
+ using System;
+ using System.Linq;
+ using System.Windows.Forms;
+
+ #endregion
+
/// <summary>
/// An <see cref="IElementOps{TElement}"/> implementation for <see
cref="Control"/>
/// from Windows Forms.
=======================================
--- /Fizzler.Sandbox/WinForms/ControlSelection.cs Wed Apr 29 10:23:40 2009
+++ /Fizzler.Sandbox/WinForms/ControlSelection.cs Tue Feb 2 14:28:39 2010
@@ -1,9 +1,13 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Forms;
-
-namespace Fizzler.Systems.WinForms
+namespace Fizzler.Systems.WinForms
{
+ #region Imports
+
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Windows.Forms;
+
+ #endregion
+
/// <summary>
/// Selectors API for <see cref="Control"/>.
/// </summary>
=======================================
--- /Fizzler.Sandbox/Xml/XmlNodeExtensions.cs Wed Sep 30 10:53:50 2009
+++ /Fizzler.Sandbox/Xml/XmlNodeExtensions.cs Tue Feb 2 14:28:39 2010
@@ -1,12 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Xml;
-
namespace Fizzler.Systems.XmlNodeQuery
{
- public static class XmlNodeExtensions
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Linq;
+ using System.Xml;
+
+ #endregion
+
+ public static class XmlNodeExtensions
{
/// <summary>
/// Determines whether this node is an element or not.
=======================================
--- /Fizzler.Sandbox/Xml/XmlNodeOps.cs Wed Sep 30 10:53:50 2009
+++ /Fizzler.Sandbox/Xml/XmlNodeOps.cs Tue Feb 2 14:28:39 2010
@@ -1,10 +1,14 @@
-using System;
-using System.Linq;
-using System.Xml;
-
namespace Fizzler.Systems.XmlNodeQuery
{
- public class XmlNodeOps : IElementOps<XmlNode>
+ #region Imports
+
+ using System;
+ using System.Linq;
+ using System.Xml;
+
+ #endregion
+
+ public class XmlNodeOps : IElementOps<XmlNode>
{
public virtual Selector<XmlNode> Type(NamespacePrefix prefix, string
type)
{
=======================================
--- /Fizzler.Sandbox/Xml/XmlNodeSelection.cs Wed Sep 30 10:53:50 2009
+++ /Fizzler.Sandbox/Xml/XmlNodeSelection.cs Tue Feb 2 14:28:39 2010
@@ -1,10 +1,14 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Xml;
-
namespace Fizzler.Systems.XmlNodeQuery
{
- public static class XmlNodeSelection
+ #region Imports
+
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Xml;
+
+ #endregion
+
+ public static class XmlNodeSelection
{
/// <summary>
/// Similar to <see cref="QuerySelectorAll" /> except it returns
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/HtmlDocumentExtensions.cs Wed Sep 30
23:20:04 2009
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlDocumentExtensions.cs Tue Feb 2
14:28:39 2010
@@ -1,10 +1,14 @@
-using System;
-using System.Collections;
-using System.Runtime.CompilerServices;
-using HtmlAgilityPack;
-
-namespace Fizzler.Systems.HtmlAgilityPack
+namespace Fizzler.Systems.HtmlAgilityPack
{
+ #region Imports
+
+ using System;
+ using System.Collections;
+ using System.Runtime.CompilerServices;
+ using global::HtmlAgilityPack;
+
+ #endregion
+
public static class HtmlDocumentExtensions
{
private static Hashtable _defaultElementFlags;
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/HtmlNodeExtensions.cs Thu Apr 30
10:44:03 2009
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlNodeExtensions.cs Tue Feb 2
14:28:39 2010
@@ -1,12 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using HtmlAgilityPack;
-
namespace Fizzler.Systems.HtmlAgilityPack
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Linq;
+ using System.Text;
+ using global::HtmlAgilityPack;
+
+ #endregion
+
/// <summary>
/// HtmlNode extension methods.
/// </summary>
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs Tue Jun 2 06:47:04 2009
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs Tue Feb 2 14:28:39 2010
@@ -1,9 +1,13 @@
-using System;
-using System.Linq;
-using HtmlAgilityPack;
-
namespace Fizzler.Systems.HtmlAgilityPack
{
+ #region Imports
+
+ using System;
+ using System.Linq;
+ using global::HtmlAgilityPack;
+
+ #endregion
+
/// <summary>
/// An <see cref="IElementOps{TElement}"/> implementation for <see
cref="HtmlNode"/>
/// from <a
href="
http://www.codeplex.com/htmlagilitypack">HtmlAgilityPack</a>.
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/HtmlNodeSelection.cs Wed Nov 11
17:13:55 2009
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlNodeSelection.cs Tue Feb 2
14:28:39 2010
@@ -1,10 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using HtmlAgilityPack;
-
-namespace Fizzler.Systems.HtmlAgilityPack
+namespace Fizzler.Systems.HtmlAgilityPack
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using global::HtmlAgilityPack;
+
+ #endregion
+
/// <summary>
/// Selector API for <see cref="HtmlNode"/>.
/// </summary>
=======================================
--- /Fizzler.Tests/AttributeSelectors.cs Fri May 1 09:55:06 2009
+++ /Fizzler.Tests/AttributeSelectors.cs Tue Feb 2 14:28:39 2010
@@ -1,10 +1,8 @@
-using System.Collections.Generic;
-using HtmlAgilityPack;
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
- [TestFixture]
+ using NUnit.Framework;
+
+ [TestFixture]
public class AttributeSelectors : SelectorBaseTest
{
[Test]
=======================================
--- /Fizzler.Tests/ChildAndAdjacentSelectors.cs Tue May 12 03:57:47 2009
+++ /Fizzler.Tests/ChildAndAdjacentSelectors.cs Tue Feb 2 14:28:39 2010
@@ -1,8 +1,8 @@
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
- [TestFixture]
+ using NUnit.Framework;
+
+ [TestFixture]
public class ChildAndAdjacentSelectors : SelectorBaseTest
{
[Test]
=======================================
--- /Fizzler.Tests/ClassSelector.cs Mon Apr 27 14:56:01 2009
+++ /Fizzler.Tests/ClassSelector.cs Tue Feb 2 14:28:39 2010
@@ -1,8 +1,8 @@
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
- [TestFixture]
+ using NUnit.Framework;
+
+ [TestFixture]
public class ClassSelector : SelectorBaseTest
{
[Test]
=======================================
--- /Fizzler.Tests/ElementSelector.cs Wed Sep 30 23:20:04 2009
+++ /Fizzler.Tests/ElementSelector.cs Tue Feb 2 14:28:39 2010
@@ -1,9 +1,9 @@
-using System;
-using NUnit.Framework;
-
-namespace Fizzler.Tests
+namespace Fizzler.Tests
{
- [TestFixture]
+ using System;
+ using NUnit.Framework;
+
+ [TestFixture]
public class ElementSelector : SelectorBaseTest
{
[Test]
=======================================
--- /Fizzler.Tests/HumanReadableSelectorGeneratorTests.cs Fri May 15
07:36:58 2009
+++ /Fizzler.Tests/HumanReadableSelectorGeneratorTests.cs Tue Feb 2
14:28:39 2010
@@ -1,9 +1,9 @@
-using System;
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
- [TestFixture]
+ using System;
+ using NUnit.Framework;
+
+ [TestFixture]
public class HumanReadableSelectorGeneratorTests
{
public class TestHumanReadableSelectorGenerator :
HumanReadableSelectorGenerator
=======================================
--- /Fizzler.Tests/IDSelector.cs Mon Apr 27 14:56:01 2009
+++ /Fizzler.Tests/IDSelector.cs Tue Feb 2 14:28:39 2010
@@ -1,8 +1,8 @@
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
- [TestFixture]
+ using NUnit.Framework;
+
+ [TestFixture]
public class IDSelector : SelectorBaseTest
{
[Test]
=======================================
--- /Fizzler.Tests/MultipleSelectors.cs Mon Apr 27 14:56:01 2009
+++ /Fizzler.Tests/MultipleSelectors.cs Tue Feb 2 14:28:39 2010
@@ -1,8 +1,8 @@
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
- [TestFixture]
+ using NUnit.Framework;
+
+ [TestFixture]
public class MultipleSelectors : SelectorBaseTest
{
[Test]
=======================================
--- /Fizzler.Tests/NamespacePrefixTests.cs Tue Jun 2 06:35:41 2009
+++ /Fizzler.Tests/NamespacePrefixTests.cs Tue Feb 2 14:28:39 2010
@@ -1,8 +1,8 @@
-using NUnit.Framework;
-using NUnit.Framework.SyntaxHelpers;
-
namespace Fizzler.Tests
{
+ using NUnit.Framework;
+ using NUnit.Framework.SyntaxHelpers;
+
[TestFixture]
public class NamespacePrefixTests
{
=======================================
--- /Fizzler.Tests/NthChild.cs Mon Apr 27 14:56:01 2009
+++ /Fizzler.Tests/NthChild.cs Tue Feb 2 14:28:39 2010
@@ -1,8 +1,8 @@
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
- [TestFixture]
+ using NUnit.Framework;
+
+ [TestFixture]
public class NthChild : SelectorBaseTest
{
/// <summary>
=======================================
--- /Fizzler.Tests/ParserTests.cs Tue Jun 2 10:06:28 2009
+++ /Fizzler.Tests/ParserTests.cs Tue Feb 2 14:28:39 2010
@@ -1,10 +1,14 @@
-using System;
-using System.Collections.Generic;
-using NUnit.Framework;
-using NUnit.Framework.SyntaxHelpers;
-
namespace Fizzler.Tests
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using NUnit.Framework;
+ using NUnit.Framework.SyntaxHelpers;
+
+ #endregion
+
[TestFixture]
public class ParserTests
{
=======================================
--- /Fizzler.Tests/PsuedoSelectors.cs Wed Sep 30 23:20:04 2009
+++ /Fizzler.Tests/PsuedoSelectors.cs Tue Feb 2 14:28:39 2010
@@ -1,7 +1,7 @@
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
+ using NUnit.Framework;
+
[TestFixture]
public class PsuedoSelectors : SelectorBaseTest
{
=======================================
--- /Fizzler.Tests/ReaderTests.cs Mon May 18 04:04:15 2009
+++ /Fizzler.Tests/ReaderTests.cs Tue Feb 2 14:28:39 2010
@@ -1,10 +1,14 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
+ #region Imports
+
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using NUnit.Framework;
+
+ #endregion
+
[TestFixture]
public class ReaderTests
{
=======================================
--- /Fizzler.Tests/SelectorBaseTest.cs Wed Sep 30 23:20:04 2009
+++ /Fizzler.Tests/SelectorBaseTest.cs Tue Feb 2 14:28:39 2010
@@ -1,15 +1,19 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using Fizzler.Systems.HtmlAgilityPack;
-using HtmlAgilityPack;
-
namespace Fizzler.Tests
{
- public abstract class SelectorBaseTest
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Collections.ObjectModel;
+ using System.IO;
+ using System.Linq;
+ using System.Reflection;
+ using Fizzler.Systems.HtmlAgilityPack;
+ using HtmlAgilityPack;
+
+ #endregion
+
+ public abstract class SelectorBaseTest
{
protected SelectorBaseTest()
{
=======================================
--- /Fizzler.Tests/SelectorGeneratorTeeTests.cs Tue Jun 2 06:54:52 2009
+++ /Fizzler.Tests/SelectorGeneratorTeeTests.cs Tue Feb 2 14:28:39 2010
@@ -1,12 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
- /// <summary>
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Reflection;
+ using NUnit.Framework;
+
+ #endregion
+
+ /// <summary>
/// Ensure that all actions on SelectorGeneratorTee are passed
/// to the internal Primary and Secondary SelectorGenerators.
/// </summary>
=======================================
--- /Fizzler.Tests/TokenTests.cs Wed Jun 3 13:26:53 2009
+++ /Fizzler.Tests/TokenTests.cs Tue Feb 2 14:28:39 2010
@@ -1,9 +1,13 @@
-using System;
-using NUnit.Framework;
-using NUnit.Framework.SyntaxHelpers;
-
-namespace Fizzler.Tests
+namespace Fizzler.Tests
{
+ #region Imports
+
+ using System;
+ using NUnit.Framework;
+ using NUnit.Framework.SyntaxHelpers;
+
+ #endregion
+
[TestFixture]
public class TokenTests
{
=======================================
--- /Fizzler.Tests/TokenerTests.cs Wed Jun 3 13:26:53 2009
+++ /Fizzler.Tests/TokenerTests.cs Tue Feb 2 14:28:39 2010
@@ -1,10 +1,14 @@
-using System;
-using System.IO;
-using System.Linq;
-using NUnit.Framework;
-
namespace Fizzler.Tests
{
+ #region Imports
+
+ using System;
+ using System.IO;
+ using System.Linq;
+ using NUnit.Framework;
+
+ #endregion
+
[TestFixture]
public class TokenerTests
{
=======================================
--- /Fizzler/Either.cs Wed Jun 3 13:26:53 2009
+++ /Fizzler/Either.cs Tue Feb 2 14:28:39 2010
@@ -21,11 +21,15 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-using System.Collections.Generic;
-
namespace Fizzler
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+
+ #endregion
+
// Adapted from Mono Rocks
internal abstract class Either<TA, TB>
=======================================
--- /Fizzler/HumanReadableSelectorGenerator.cs Tue Jun 2 06:47:04 2009
+++ /Fizzler/HumanReadableSelectorGenerator.cs Tue Feb 2 14:28:39 2010
@@ -1,7 +1,7 @@
-using System;
-
namespace Fizzler
{
+ using System;
+
/// <summary>
/// An <see cref="ISelectorGenerator"/> implementation that generates
/// human-readable description of the selector.
=======================================
--- /Fizzler/NamespacePrefix.cs Tue Jun 2 06:35:41 2009
+++ /Fizzler/NamespacePrefix.cs Tue Feb 2 14:28:39 2010
@@ -1,7 +1,7 @@
-using System;
-
-namespace Fizzler
+namespace Fizzler
{
+ using System;
+
/// <summary>
/// Represent a type or attribute name.
/// </summary>
=======================================
--- /Fizzler/Parser.cs Sat Oct 31 12:19:36 2009
+++ /Fizzler/Parser.cs Tue Feb 2 14:28:39 2010
@@ -1,13 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Globalization;
-using System.Linq;
-
namespace Fizzler
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Globalization;
+ using System.Linq;
+
using TokenSpec = Either<TokenKind, Token>;
+ #endregion
+
/// <summary>
/// Semantic parser for CSS selector grammar.
/// </summary>
=======================================
--- /Fizzler/Reader.cs Mon May 18 04:03:54 2009
+++ /Fizzler/Reader.cs Tue Feb 2 14:28:39 2010
@@ -1,9 +1,13 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace Fizzler
+namespace Fizzler
{
+ #region Imports
+
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+
+ #endregion
+
/// <summary>
/// Adds reading semantics to a base <see cref="IEnumerator{T}"/> with
the
/// option to un-read and insert new elements while consuming the
source.
=======================================
--- /Fizzler/Selector.cs Fri May 1 10:02:24 2009
+++ /Fizzler/Selector.cs Tue Feb 2 14:28:39 2010
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
-
namespace Fizzler
{
+ using System.Collections.Generic;
+
/// <summary>
/// Represents a selector implementation over an arbitrary type of
elements.
/// </summary>
=======================================
--- /Fizzler/SelectorGenerator.cs Tue Jun 2 06:47:04 2009
+++ /Fizzler/SelectorGenerator.cs Tue Feb 2 14:28:39 2010
@@ -1,9 +1,13 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
namespace Fizzler
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ #endregion
+
/// <summary>
/// A selector generator implementation for an arbitrary
document/element system.
/// </summary>
=======================================
--- /Fizzler/SelectorGeneratorTee.cs Tue Jun 2 06:47:04 2009
+++ /Fizzler/SelectorGeneratorTee.cs Tue Feb 2 14:28:39 2010
@@ -1,7 +1,7 @@
-using System;
-
namespace Fizzler
{
+ using System;
+
/// <summary>
/// An <see cref="ISelectorGenerator"/> implementation that delegates
/// to two other <see cref="ISelectorGenerator"/> objects, which
=======================================
--- /Fizzler/SelectorsCachingCompiler.cs Wed Nov 11 17:13:55 2009
+++ /Fizzler/SelectorsCachingCompiler.cs Tue Feb 2 14:28:39 2010
@@ -1,12 +1,10 @@
-using System.Diagnostics;
-
namespace Fizzler
{
#region Imports
using System;
using System.Collections.Generic;
- using System.Linq;
+ using System.Diagnostics;
#endregion
=======================================
--- /Fizzler/Token.cs Wed Jun 3 13:26:53 2009
+++ /Fizzler/Token.cs Tue Feb 2 14:28:39 2010
@@ -1,7 +1,7 @@
-using System;
-
namespace Fizzler
{
+ using System;
+
/// <summary>
/// Represent a token and optionally any text associated with it.
/// </summary>
=======================================
--- /Fizzler/Tokener.cs Wed Jun 3 13:26:53 2009
+++ /Fizzler/Tokener.cs Tue Feb 2 14:28:39 2010
@@ -1,11 +1,15 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Text;
-
-namespace Fizzler
+namespace Fizzler
{
+ #region Imports
+
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Text;
+
+ #endregion
+
/// <summary>
/// Lexer for tokens in CSS selector grammar.
/// </summary>
==============================================================================
Revision: 978fa1985ace
Branch: default
Author: azizatif
Date: Tue Feb 2 14:46:14 2010
Log: Updated ConsoleFizzler to use string extensions from Mannex.
http://code.google.com/p/fizzler/source/detail?r=978fa1985ace
Modified:
/ConsoleFizzler/CommandLine.cs
/ConsoleFizzler/ConsoleFizzler.csproj
/ConsoleFizzler/StringExtensions.cs
=======================================
--- /ConsoleFizzler/CommandLine.cs Tue Feb 2 14:28:39 2010
+++ /ConsoleFizzler/CommandLine.cs Tue Feb 2 14:46:14 2010
@@ -1,4 +1,6 @@
-namespace ConsoleFizzler
+using Mannex;
+
+namespace ConsoleFizzler
{
#region Imports
@@ -106,10 +108,10 @@
// Allows `arg=value` or `arg:value` style.
var paired = name.IndexOfAny(_argSeparators) > 0;
- var pair = name.SplitPair(_argSeparators);
+ var pair = name.Split(_argSeparators, (n, v) => new { Name
= n, Value = v });
if (paired)
- name = pair.Key; // Break the name out of the pair
+ name = pair.Name; // Break the name out of the pair
// Get setting property from name.
=======================================
--- /ConsoleFizzler/ConsoleFizzler.csproj Wed May 20 02:18:25 2009
+++ /ConsoleFizzler/ConsoleFizzler.csproj Tue Feb 2 14:46:14 2010
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)'
== '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{296C2824-A7D7-42A0-9B4C-1BC8FA0A1859}</ProjectGuid>
<OutputType>Exe</OutputType>
@@ -36,6 +36,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\HtmlAgilityPack.dll</HintPath>
</Reference>
+ <Reference Include="Mannex, Version=1.0.12026.0, Culture=neutral,
processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Libs\Mannex.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
=======================================
--- /ConsoleFizzler/StringExtensions.cs Tue Feb 2 14:28:39 2010
+++ /ConsoleFizzler/StringExtensions.cs Tue Feb 2 14:46:14 2010
@@ -2,66 +2,12 @@
{
#region Imports
- using System;
- using System.Collections.Generic;
using System.Globalization;
#endregion
static class StringExtensions
{
- /// <summary>
- /// Splits a string into a key and a value part using a specified
- /// character to separate the two.
- /// </summary>
- /// <remarks>
- /// The key or value of the resulting pair is never <c>null</c>.
- /// </remarks>
-
- public static KeyValuePair<string, string> SplitPair(this string
str, char separator)
- {
- if (str == null) throw new ArgumentNullException("str");
-
- return SplitPair(str, str.IndexOf(separator), 1);
- }
-
- /// <summary>
- /// Splits a string into a key and a value part using any of a
- /// specified set of characters to separate the two.
- /// </summary>
- /// <remarks>
- /// The key or value of the resulting pair is never <c>null</c>.
- /// </remarks>
-
- public static KeyValuePair<string, string> SplitPair(this string
str, params char[] separators)
- {
- if (str == null) throw new ArgumentNullException("str");
-
- return separators == null || separators.Length == 0
- ? new KeyValuePair<string, string>(str,
string.Empty)
- : SplitPair(str, str.IndexOfAny(separators), 1);
- }
-
- /// <summary>
- /// Splits a string into a key and a value part by removing a
- /// portion of the string.
- /// </summary>
- /// <remarks>
- /// The key or value of the resulting pair is never <c>null</c>.
- /// </remarks>
-
- public static KeyValuePair<string, string> SplitPair(this string
str, int index, int count)
- {
- if (str == null) throw new ArgumentNullException("str");
- if (count <= 0) throw new ArgumentOutOfRangeException("count",
count, null);
-
- return new KeyValuePair<string, string>(
- /* key */ index < 0 ? str : str.Substring(0, index),
- /* value */ index < 0 || index + 1 >=
str.Length
- ? string.Empty
- : str.Substring(index
+ count));
- }
-
/// <summary>
/// Converts the specified string to titlecase using the invariant
culture.
/// </summary>
==============================================================================
Revision: cb8d492a9209
Branch: default
Author: azizatif
Date: Wed Oct 6 16:15:18 2010
Log: Implemented issue #27, "Support nth-last-child pseudo-class
selector", thanks to patch submitted by edin.dazdarevic [1].
[1]
http://code.google.com/u/edin.dazdarevic/
http://code.google.com/p/fizzler/source/detail?r=cb8d492a9209
Added:
/Fizzler.Tests/NthLastChild.cs
Modified:
/Fizzler.Sandbox/WinForms/ControlOps.cs
/Fizzler.Sandbox/Xml/XmlNodeOps.cs
/Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs
/Fizzler.Tests/Fizzler.Tests.csproj
/Fizzler.Tests/ParserTests.cs
/Fizzler.Tests/SelectorGeneratorTeeTests.cs
/Fizzler/HumanReadableSelectorGenerator.cs
/Fizzler/IElementOps.cs
/Fizzler/ISelectorGenerator.cs
/Fizzler/Parser.cs
/Fizzler/SelectorGenerator.cs
/Fizzler/SelectorGeneratorTee.cs
=======================================
--- /dev/null
+++ /Fizzler.Tests/NthLastChild.cs Wed Oct 6 16:15:18 2010
@@ -0,0 +1,48 @@
+
+namespace Fizzler.Tests
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class NthLastChild : SelectorBaseTest
+ {
+ [Test]
+ public void No_Prefix_With_Digit()
+ {
+ var result = SelectList(":nth-last-child(2)");
+
+ Assert.AreEqual(4, result.Count);
+ Assert.AreEqual("head", result[0].Name);
+ Assert.AreEqual("div", result[1].Name);
+ Assert.AreEqual("span", result[2].Name);
+ Assert.AreEqual("div", result[3].Name);
+ }
+
+ [Test]
+ public void Id_Prefix_With_Digit()
+ {
+ var result = SelectList("#myDiv :nth-last-child(2)");
+
+ Assert.AreEqual(2, result.Count);
+ Assert.AreEqual("div", result[0].Name);
+ Assert.AreEqual("span", result[1].Name);
+ }
+
+ [Test]
+ public void Element_Prefix_With_Digit()
+ {
+ var result = SelectList("span:nth-last-child(3)");
+
+ Assert.AreEqual(0, result.Count);
+ }
+
+ [Test]
+ public void Element_Prefix_With_Digit2()
+ {
+ var result = SelectList("span:nth-last-child(2)");
+
+ Assert.AreEqual(1, result.Count);
+ Assert.AreEqual("span", result[0].Name);
+ }
+ }
+}
=======================================
--- /Fizzler.Sandbox/WinForms/ControlOps.cs Tue Feb 2 14:28:39 2010
+++ /Fizzler.Sandbox/WinForms/ControlOps.cs Wed Oct 6 16:15:18 2010
@@ -247,5 +247,10 @@
{
return nodes => nodes.SelectMany(n => n.ControlsAfterSelf());
}
+
+ public Selector<Control> NthLastChild(int a, int b)
+ {
+ throw new NotImplementedException();
+ }
}
}
=======================================
--- /Fizzler.Sandbox/Xml/XmlNodeOps.cs Tue Feb 2 14:28:39 2010
+++ /Fizzler.Sandbox/Xml/XmlNodeOps.cs Wed Oct 6 16:15:18 2010
@@ -190,5 +190,20 @@
{
return nodes => nodes.SelectMany(n => n.ElementsAfterSelf());
}
+
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child from bottom up of
some other element.
+ /// </summary>
+ public Selector<XmlNode> NthLastChild(int a, int b)
+ {
+ if (a != 1)
+ throw new NotSupportedException("The nth-last-child(an+b) selector
where a in is not 1 are not supported.");
+
+ return nodes => from n in nodes
+ let elements = n.ParentNode.Elements().Skip(Math.Max(0,
n.ParentNode.Elements().Count() - b)).Take(b).ToArray()
+ where elements.Length == b && elements.First().Equals(n)
+ select n;
+ }
}
}
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs Tue Feb 2 14:28:39 2010
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs Wed Oct 6 16:15:18 2010
@@ -258,5 +258,20 @@
{
return nodes => nodes.SelectMany(n => n.ElementsAfterSelf());
}
+
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child from bottom up of
some other element.
+ /// </summary>
+ public Selector<HtmlNode> NthLastChild(int a, int b)
+ {
+ if (a != 1)
+ throw new NotSupportedException("The nth-last-child(an+b) selector
where a in is not 1 are not supported.");
+
+ return nodes => from n in nodes
+ let elements = n.ParentNode.Elements().Skip(Math.Max(0,
n.ParentNode.Elements().Count() - b)).Take(b).ToArray()
+ where elements.Length == b && elements.First().Equals(n)
+ select n;
+ }
}
}
=======================================
--- /Fizzler.Tests/Fizzler.Tests.csproj Wed Sep 30 10:53:50 2009
+++ /Fizzler.Tests/Fizzler.Tests.csproj Wed Oct 6 16:15:18 2010
@@ -49,6 +49,7 @@
<Compile Include="AttributeSelectors.cs" />
<Compile Include="ChildAndAdjacentSelectors.cs" />
<Compile Include="ClassSelector.cs" />
+ <Compile Include="NthLastChild.cs" />
<Compile Include="ParserTests.cs" />
<Compile Include="HumanReadableSelectorGeneratorTests.cs" />
<Compile Include="IDSelector.cs" />
=======================================
--- /Fizzler.Tests/ParserTests.cs Tue Feb 2 14:28:39 2010
+++ /Fizzler.Tests/ParserTests.cs Wed Oct 6 16:15:18 2010
@@ -484,7 +484,12 @@
throw new NotImplementedException();
}
- #endregion
+ public void NthLastChild(int a, int b)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
}
}
}
=======================================
--- /Fizzler.Tests/SelectorGeneratorTeeTests.cs Tue Feb 2 14:28:39 2010
+++ /Fizzler.Tests/SelectorGeneratorTeeTests.cs Wed Oct 6 16:15:18 2010
@@ -369,8 +369,13 @@
{
OnInvoked(MethodBase.GetCurrentMethod());
}
-
- private void OnInvoked(MethodBase method, params object[] args)
+
+ public void NthLastChild(int a, int b)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), a, b);
+ }
+
+ private void OnInvoked(MethodBase method, params object[] args)
{
Recorder(new CallRecording<ISelectorGenerator>(this,
(MethodInfo) method, args));
}
=======================================
--- /Fizzler/HumanReadableSelectorGenerator.cs Tue Feb 2 14:28:39 2010
+++ /Fizzler/HumanReadableSelectorGenerator.cs Wed Oct 6 16:15:18 2010
@@ -228,5 +228,13 @@
{
Add(", then take their siblings which are");
}
+
+ /// <summary>
+ /// Generates human-readable text of this combinator.
+ /// </summary>
+ public void NthLastChild(int a, int b)
+ {
+ Add(string.Format(" where the element has {0}n+{1}-1 sibling after it",
a, b));
+ }
}
}
=======================================
--- /Fizzler/IElementOps.cs Tue Jun 2 06:47:04 2009
+++ /Fizzler/IElementOps.cs Wed Oct 6 16:15:18 2010
@@ -159,5 +159,11 @@
/// immediately) the element represented by the second one.
/// </summary>
Selector<TElement> GeneralSibling();
+
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child from bottom up of
some other element.
+ /// </summary>
+ Selector<TElement> NthLastChild(int a, int b);
}
}
=======================================
--- /Fizzler/ISelectorGenerator.cs Tue Jun 2 06:47:04 2009
+++ /Fizzler/ISelectorGenerator.cs Wed Oct 6 16:15:18 2010
@@ -175,5 +175,11 @@
/// immediately) the element represented by the second one.
/// </summary>
void GeneralSibling();
+
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child from bottom up of
some other element.
+ /// </summary>
+ void NthLastChild(int a, int b);
}
}
=======================================
--- /Fizzler/Parser.cs Tue Feb 2 14:28:39 2010
+++ /Fizzler/Parser.cs Wed Oct 6 16:15:18 2010
@@ -238,10 +238,11 @@
switch (func)
{
case "nth-child": Nth(); break;
+ case "nth-last-child": NthLast(); break;
default:
{
throw new FormatException(string.Format(
- "Unknown functional pseudo '{0}'. Only nth-child
is supported.", func));
+ "Unknown functional pseudo '{0}'. Only nth-child
and nth-last-child is supported.", func));
}
}
@@ -262,6 +263,20 @@
var b = int.Parse(Read(ToTokenSpec(TokenKind.Integer)).Text,
CultureInfo.InvariantCulture);
_generator.NthChild(1, b);
}
+
+ private void NthLast()
+ {
+ //nth
+ // : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
+ // ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
+ // ;
+
+ // TODO Add support for the full syntax
+ // At present, only INTEGER is allowed
+
+ var b = int.Parse(Read(ToTokenSpec(TokenKind.Integer)).Text,
CultureInfo.InvariantCulture);
+ _generator.NthLastChild(1, b);
+ }
private void Attrib()
{
=======================================
--- /Fizzler/SelectorGenerator.cs Tue Feb 2 14:28:39 2010
+++ /Fizzler/SelectorGenerator.cs Wed Oct 6 16:15:18 2010
@@ -307,5 +307,14 @@
{
Add(Ops.GeneralSibling());
}
+
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child from bottom up of
some other element.
+ /// </summary>
+ public void NthLastChild(int a, int b)
+ {
+ Add(Ops.NthLastChild(a, b));
+ }
}
}
=======================================
--- /Fizzler/SelectorGeneratorTee.cs Tue Feb 2 14:28:39 2010
+++ /Fizzler/SelectorGeneratorTee.cs Wed Oct 6 16:15:18 2010
@@ -239,5 +239,14 @@
Primary.GeneralSibling();
Secondary.GeneralSibling();
}
+
+ /// <summary>
+ /// Delegates to <see cref="Primary"/> then <see cref="Secondary"/>
generator.
+ /// </summary>
+ public void NthLastChild(int a, int b)
+ {
+ Primary.NthLastChild(a, b);
+ Secondary.NthLastChild(a, b);
+ }
}
}
==============================================================================
Revision: c69bc5ee728d
Branch: default
Author: azizatif
Date: Wed Oct 6 16:24:09 2010
Log: Fixed typo in exception message.
http://code.google.com/p/fizzler/source/detail?r=c69bc5ee728d
Modified:
/Fizzler/Parser.cs
=======================================
--- /Fizzler/Parser.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler/Parser.cs Wed Oct 6 16:24:09 2010
@@ -242,7 +242,7 @@
default:
{
throw new FormatException(string.Format(
- "Unknown functional pseudo '{0}'. Only nth-child
and nth-last-child is supported.", func));
+ "Unknown functional pseudo '{0}'. Only nth-child
and nth-last-child are supported.", func));
}
}
==============================================================================
Revision: 895f6368aba0
Branch: default
Author: azizatif
Date: Wed Oct 6 16:28:04 2010
Log: Removed duplication in parsing the b component between Parser.Nth
and Parser.NthLast.
http://code.google.com/p/fizzler/source/detail?r=895f6368aba0
Modified:
/Fizzler/Parser.cs
=======================================
--- /Fizzler/Parser.cs Wed Oct 6 16:24:09 2010
+++ /Fizzler/Parser.cs Wed Oct 6 16:28:04 2010
@@ -238,7 +238,7 @@
switch (func)
{
case "nth-child": Nth(); break;
- case "nth-last-child": NthLast(); break;
+ case "nth-last-child": NthLast(); break;
default:
{
throw new FormatException(string.Format(
@@ -260,11 +260,10 @@
// TODO Add support for the full syntax
// At present, only INTEGER is allowed
- var b = int.Parse(Read(ToTokenSpec(TokenKind.Integer)).Text,
CultureInfo.InvariantCulture);
- _generator.NthChild(1, b);
+ _generator.NthChild(1, NthB());
}
- private void NthLast()
+ private void NthLast()
{
//nth
// : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
@@ -274,9 +273,13 @@
// TODO Add support for the full syntax
// At present, only INTEGER is allowed
- var b = int.Parse(Read(ToTokenSpec(TokenKind.Integer)).Text,
CultureInfo.InvariantCulture);
- _generator.NthLastChild(1, b);
+ _generator.NthLastChild(1, NthB());
}
+
+ private int NthB()
+ {
+ return int.Parse(Read(ToTokenSpec(TokenKind.Integer)).Text,
CultureInfo.InvariantCulture);
+ }
private void Attrib()
{
==============================================================================
Revision: efb2858f4429
Branch: default
Author: azizatif
Date: Wed Oct 6 16:35:37 2010
Log: Fixed formatting/indentation issues due to mixed use of tabs and
spaces.
http://code.google.com/p/fizzler/source/detail?r=efb2858f4429
Modified:
/Fizzler.Sandbox/WinForms/ControlOps.cs
/Fizzler.Sandbox/Xml/XmlNodeOps.cs
/Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs
/Fizzler.Tests/NthLastChild.cs
/Fizzler.Tests/ParserTests.cs
/Fizzler.Tests/SelectorGeneratorTeeTests.cs
/Fizzler/HumanReadableSelectorGenerator.cs
/Fizzler/ISelectorGenerator.cs
/Fizzler/Parser.cs
/Fizzler/SelectorGenerator.cs
/Fizzler/SelectorGeneratorTee.cs
=======================================
--- /Fizzler.Sandbox/WinForms/ControlOps.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler.Sandbox/WinForms/ControlOps.cs Wed Oct 6 16:35:37 2010
@@ -236,21 +236,21 @@
return controls => controls.SelectMany(c =>
c.ControlsAfterSelf().Take(1));
}
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
- /// which separates two sequences of simple selectors. The elements
represented
- /// by the two sequences share the same parent in the document tree
and the
- /// element represented by the first sequence precedes (not
necessarily
- /// immediately) the element represented by the second one.
- /// </summary>
- public virtual Selector<Control> GeneralSibling()
- {
- return nodes => nodes.SelectMany(n => n.ControlsAfterSelf());
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
+ /// which separates two sequences of simple selectors. The
elements represented
+ /// by the two sequences share the same parent in the document
tree and the
+ /// element represented by the first sequence precedes (not
necessarily
+ /// immediately) the element represented by the second one.
+ /// </summary>
+ public virtual Selector<Control> GeneralSibling()
+ {
+ return nodes => nodes.SelectMany(n => n.ControlsAfterSelf());
+ }
- public Selector<Control> NthLastChild(int a, int b)
- {
- throw new NotImplementedException();
- }
+ public Selector<Control> NthLastChild(int a, int b)
+ {
+ throw new NotImplementedException();
+ }
}
}
=======================================
--- /Fizzler.Sandbox/Xml/XmlNodeOps.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler.Sandbox/Xml/XmlNodeOps.cs Wed Oct 6 16:35:37 2010
@@ -9,201 +9,201 @@
#endregion
public class XmlNodeOps : IElementOps<XmlNode>
- {
- public virtual Selector<XmlNode> Type(NamespacePrefix prefix, string
type)
- {
+ {
+ public virtual Selector<XmlNode> Type(NamespacePrefix prefix,
string type)
+ {
// TODO Proper namespace support
return nodes => nodes.Where(n => n.Name == type);
- }
+ }
- public virtual Selector<XmlNode> Universal(NamespacePrefix prefix)
- {
+ public virtual Selector<XmlNode> Universal(NamespacePrefix prefix)
+ {
// TODO Proper namespace support
return nodes => nodes.Elements();
- }
+ }
- public virtual Selector<XmlNode> Id(string id)
- {
- return AttributeExact(NamespacePrefix.None, "id", id);
- }
+ public virtual Selector<XmlNode> Id(string id)
+ {
+ return AttributeExact(NamespacePrefix.None, "id", id);
+ }
- public virtual Selector<XmlNode> Class(string clazz)
- {
- return AttributeIncludes(NamespacePrefix.None, "class", clazz);
- }
+ public virtual Selector<XmlNode> Class(string clazz)
+ {
+ return AttributeIncludes(NamespacePrefix.None, "class", clazz);
+ }
- public virtual Selector<XmlNode> AttributeExists(NamespacePrefix prefix,
string name)
- {
+ public virtual Selector<XmlNode> AttributeExists(NamespacePrefix
prefix, string name)
+ {
// TODO Proper namespace support
- return nodes => nodes.Elements().Where(n => n.Attributes[name] != null);
- }
+ return nodes => nodes.Elements().Where(n =>
n.Attributes[name] != null);
+ }
- public virtual Selector<XmlNode> AttributeExact(NamespacePrefix prefix,
string name, string value)
- {
+ public virtual Selector<XmlNode> AttributeExact(NamespacePrefix
prefix, string name, string value)
+ {
// TODO Proper namespace support
return nodes => from n in nodes.Elements()
- let a = n.Attributes[name]
- where a != null && a.Value == value
- select n;
- }
+ let a = n.Attributes[name]
+ where a != null && a.Value == value
+ select n;
+ }
- public virtual Selector<XmlNode> AttributeIncludes(NamespacePrefix
prefix, string name, string value)
- {
+ public virtual Selector<XmlNode> AttributeIncludes(NamespacePrefix
prefix, string name, string value)
+ {
// TODO Proper namespace support
return nodes => from n in nodes.Elements()
- let a = n.Attributes[name]
- where a != null && a.Value.Split(' ').Contains(value)
- select n;
- }
+ let a = n.Attributes[name]
+ where a != null &&
a.Value.Split(' ').Contains(value)
+ select n;
+ }
- public virtual Selector<XmlNode> AttributeDashMatch(NamespacePrefix
prefix, string name, string value)
- {
+ public virtual Selector<XmlNode>
AttributeDashMatch(NamespacePrefix prefix, string name, string value)
+ {
// TODO Proper namespace support
return string.IsNullOrEmpty(value)
- ? (Selector<XmlNode>)(nodes => Enumerable.Empty<XmlNode>())
- : (nodes => from n in nodes.Elements()
- let a = n.Attributes[name]
- where a != null && a.Value.Split('-').Contains(value)
- select n);
- }
+ ? (Selector<XmlNode>)(nodes =>
Enumerable.Empty<XmlNode>())
+ : (nodes => from n in nodes.Elements()
+ let a = n.Attributes[name]
+ where a != null &&
a.Value.Split('-').Contains(value)
+ select n);
+ }
- public virtual Selector<XmlNode> AttributePrefixMatch(NamespacePrefix
prefix, string name, string value)
- {
+ public virtual Selector<XmlNode>
AttributePrefixMatch(NamespacePrefix prefix, string name, string value)
+ {
// TODO Proper namespace support
return string.IsNullOrEmpty(value)
- ? (Selector<XmlNode>)(nodes => Enumerable.Empty<XmlNode>())
- : (nodes => from n in nodes.Elements()
- let a = n.Attributes[name]
- where a != null && a.Value.StartsWith(value)
- select n);
- }
+ ? (Selector<XmlNode>)(nodes =>
Enumerable.Empty<XmlNode>())
+ : (nodes => from n in nodes.Elements()
+ let a = n.Attributes[name]
+ where a != null && a.Value.StartsWith(value)
+ select n);
+ }
- public virtual Selector<XmlNode> AttributeSuffixMatch(NamespacePrefix
prefix, string name, string value)
- {
+ public virtual Selector<XmlNode>
AttributeSuffixMatch(NamespacePrefix prefix, string name, string value)
+ {
// TODO Proper namespace support
return string.IsNullOrEmpty(value)
- ? (Selector<XmlNode>)(nodes => Enumerable.Empty<XmlNode>())
- : (nodes => from n in nodes.Elements()
- let a = n.Attributes[name]
- where a != null && a.Value.EndsWith(value)
- select n);
- }
+ ? (Selector<XmlNode>)(nodes =>
Enumerable.Empty<XmlNode>())
+ : (nodes => from n in nodes.Elements()
+ let a = n.Attributes[name]
+ where a != null && a.Value.EndsWith(value)
+ select n);
+ }
- public virtual Selector<XmlNode> AttributeSubstring(NamespacePrefix
prefix, string name, string value)
- {
+ public virtual Selector<XmlNode>
AttributeSubstring(NamespacePrefix prefix, string name, string value)
+ {
// TODO Proper namespace support
return string.IsNullOrEmpty(value)
- ? (Selector<XmlNode>)(nodes => Enumerable.Empty<XmlNode>())
- : (nodes => from n in nodes.Elements()
- let a = n.Attributes[name]
- where a != null && a.Value.Contains(value)
- select n);
- }
+ ? (Selector<XmlNode>)(nodes =>
Enumerable.Empty<XmlNode>())
+ : (nodes => from n in nodes.Elements()
+ let a = n.Attributes[name]
+ where a != null && a.Value.Contains(value)
+ select n);
+ }
- public virtual Selector<XmlNode> FirstChild()
- {
- return nodes => nodes.Where(n => !n.ElementsBeforeSelf().Any());
- }
+ public virtual Selector<XmlNode> FirstChild()
+ {
+ return nodes => nodes.Where(n
=> !n.ElementsBeforeSelf().Any());
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
- /// which represents an element that is the last child of some other
element.
- /// </summary>
- public virtual Selector<XmlNode> LastChild()
- {
- return nodes => nodes.Where(n => n.ParentNode.NodeType !=
XmlNodeType.Document
- && !n.ElementsAfterSelf().Any());
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the last child of some
other element.
+ /// </summary>
+ public virtual Selector<XmlNode> LastChild()
+ {
+ return nodes => nodes.Where(n => n.ParentNode.NodeType !=
XmlNodeType.Document
+ && !n.ElementsAfterSelf().Any());
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
- /// which represents an element that is the N-th child of some other
element.
- /// </summary>
- public virtual Selector<XmlNode> NthChild(int a, int b)
- {
- if (a != 1)
- throw new NotSupportedException("The nth-child(an+b) selector where a
in is not 1 are not supported.");
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child of some
other element.
+ /// </summary>
+ public virtual Selector<XmlNode> NthChild(int a, int b)
+ {
+ if (a != 1)
+ throw new NotSupportedException("The nth-child(an+b)
selector where a in is not 1 are not supported.");
- return nodes => from n in nodes
- let elements = n.ParentNode.Elements().Take(b).ToArray()
- where elements.Length == b && elements.Last().Equals(n)
- select n;
- }
+ return nodes => from n in nodes
+ let elements =
n.ParentNode.Elements().Take(b).ToArray()
+ where elements.Length == b &&
elements.Last().Equals(n)
+ select n;
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
- /// which represents an element that has a parent element and whose
parent
- /// element has no other element children.
- /// </summary>
- public virtual Selector<XmlNode> OnlyChild()
- {
- return nodes => nodes.Where(n => n.ParentNode.NodeType !=
XmlNodeType.Document
-
&& !n.ElementsAfterSelf().Concat(n.ElementsBeforeSelf()).Any());
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that has a parent element and
whose parent
+ /// element has no other element children.
+ /// </summary>
+ public virtual Selector<XmlNode> OnlyChild()
+ {
+ return nodes => nodes.Where(n => n.ParentNode.NodeType !=
XmlNodeType.Document
+
&& !n.ElementsAfterSelf().Concat(n.ElementsBeforeSelf()).Any());
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
- /// which represents an element that has no children at all.
- /// </summary>
- public virtual Selector<XmlNode> Empty()
- {
- return nodes => nodes.Elements().Where(n => n.ChildNodes.Count == 0);
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that has no children at all.
+ /// </summary>
+ public virtual Selector<XmlNode> Empty()
+ {
+ return nodes => nodes.Elements().Where(n => n.ChildNodes.Count
== 0);
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
- /// which represents a childhood relationship between two elements.
- /// </summary>
- public virtual Selector<XmlNode> Child()
- {
- return nodes => nodes.SelectMany(n => n.Elements());
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
+ /// which represents a childhood relationship between two elements.
+ /// </summary>
+ public virtual Selector<XmlNode> Child()
+ {
+ return nodes => nodes.SelectMany(n => n.Elements());
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
- /// which represents a relationship between two elements where one
element is an
- /// arbitrary descendant of some ancestor element.
- /// </summary>
- public virtual Selector<XmlNode> Descendant()
- {
- return nodes => nodes.SelectMany(n => n.Descendants().Elements());
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
+ /// which represents a relationship between two elements where one
element is an
+ /// arbitrary descendant of some ancestor element.
+ /// </summary>
+ public virtual Selector<XmlNode> Descendant()
+ {
+ return nodes => nodes.SelectMany(n =>
n.Descendants().Elements());
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
- /// which represents elements that share the same parent in the document
tree and
- /// where the first element immediately precedes the second element.
- /// </summary>
- public virtual Selector<XmlNode> Adjacent()
- {
- return nodes => nodes.SelectMany(n => n.ElementsAfterSelf().Take(1));
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
+ /// which represents elements that share the same parent in the
document tree and
+ /// where the first element immediately precedes the second
element.
+ /// </summary>
+ public virtual Selector<XmlNode> Adjacent()
+ {
+ return nodes => nodes.SelectMany(n =>
n.ElementsAfterSelf().Take(1));
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
- /// which separates two sequences of simple selectors. The elements
represented
- /// by the two sequences share the same parent in the document tree and
the
- /// element represented by the first sequence precedes (not necessarily
- /// immediately) the element represented by the second one.
- /// </summary>
- public virtual Selector<XmlNode> GeneralSibling()
- {
- return nodes => nodes.SelectMany(n => n.ElementsAfterSelf());
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
+ /// which separates two sequences of simple selectors. The
elements represented
+ /// by the two sequences share the same parent in the document
tree and the
+ /// element represented by the first sequence precedes (not
necessarily
+ /// immediately) the element represented by the second one.
+ /// </summary>
+ public virtual Selector<XmlNode> GeneralSibling()
+ {
+ return nodes => nodes.SelectMany(n => n.ElementsAfterSelf());
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
- /// which represents an element that is the N-th child from bottom up of
some other element.
- /// </summary>
- public Selector<XmlNode> NthLastChild(int a, int b)
- {
- if (a != 1)
- throw new NotSupportedException("The nth-last-child(an+b) selector
where a in is not 1 are not supported.");
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child from bottom
up of some other element.
+ /// </summary>
+ public Selector<XmlNode> NthLastChild(int a, int b)
+ {
+ if (a != 1)
+ throw new NotSupportedException("The nth-last-child(an+b)
selector where a in is not 1 are not supported.");
- return nodes => from n in nodes
- let elements = n.ParentNode.Elements().Skip(Math.Max(0,
n.ParentNode.Elements().Count() - b)).Take(b).ToArray()
- where elements.Length == b && elements.First().Equals(n)
- select n;
- }
- }
+ return nodes => from n in nodes
+ let elements =
n.ParentNode.Elements().Skip(Math.Max(0, n.ParentNode.Elements().Count() -
b)).Take(b).ToArray()
+ where elements.Length == b &&
elements.First().Equals(n)
+ select n;
+ }
+ }
}
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs Wed Oct 6 16:35:37 2010
@@ -247,31 +247,31 @@
return nodes => nodes.SelectMany(n =>
n.ElementsAfterSelf().Take(1));
}
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
- /// which separates two sequences of simple selectors. The elements
represented
- /// by the two sequences share the same parent in the document tree
and the
- /// element represented by the first sequence precedes (not
necessarily
- /// immediately) the element represented by the second one.
- /// </summary>
- public virtual Selector<HtmlNode> GeneralSibling()
- {
- return nodes => nodes.SelectMany(n => n.ElementsAfterSelf());
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
+ /// which separates two sequences of simple selectors. The
elements represented
+ /// by the two sequences share the same parent in the document
tree and the
+ /// element represented by the first sequence precedes (not
necessarily
+ /// immediately) the element represented by the second one.
+ /// </summary>
+ public virtual Selector<HtmlNode> GeneralSibling()
+ {
+ return nodes => nodes.SelectMany(n => n.ElementsAfterSelf());
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
- /// which represents an element that is the N-th child from bottom up of
some other element.
- /// </summary>
- public Selector<HtmlNode> NthLastChild(int a, int b)
- {
- if (a != 1)
- throw new NotSupportedException("The nth-last-child(an+b) selector
where a in is not 1 are not supported.");
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child from bottom
up of some other element.
+ /// </summary>
+ public Selector<HtmlNode> NthLastChild(int a, int b)
+ {
+ if (a != 1)
+ throw new NotSupportedException("The nth-last-child(an+b)
selector where a in is not 1 are not supported.");
- return nodes => from n in nodes
- let elements = n.ParentNode.Elements().Skip(Math.Max(0,
n.ParentNode.Elements().Count() - b)).Take(b).ToArray()
- where elements.Length == b && elements.First().Equals(n)
- select n;
- }
+ return nodes => from n in nodes
+ let elements =
n.ParentNode.Elements().Skip(Math.Max(0, n.ParentNode.Elements().Count() -
b)).Take(b).ToArray()
+ where elements.Length == b &&
elements.First().Equals(n)
+ select n;
+ }
}
}
=======================================
--- /Fizzler.Tests/NthLastChild.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler.Tests/NthLastChild.cs Wed Oct 6 16:35:37 2010
@@ -1,48 +1,48 @@
namespace Fizzler.Tests
{
- using NUnit.Framework;
+ using NUnit.Framework;
- [TestFixture]
- public class NthLastChild : SelectorBaseTest
- {
- [Test]
- public void No_Prefix_With_Digit()
- {
- var result = SelectList(":nth-last-child(2)");
+ [TestFixture]
+ public class NthLastChild : SelectorBaseTest
+ {
+ [Test]
+ public void No_Prefix_With_Digit()
+ {
+ var result = SelectList(":nth-last-child(2)");
- Assert.AreEqual(4, result.Count);
- Assert.AreEqual("head", result[0].Name);
- Assert.AreEqual("div", result[1].Name);
- Assert.AreEqual("span", result[2].Name);
- Assert.AreEqual("div", result[3].Name);
- }
+ Assert.AreEqual(4, result.Count);
+ Assert.AreEqual("head", result[0].Name);
+ Assert.AreEqual("div", result[1].Name);
+ Assert.AreEqual("span", result[2].Name);
+ Assert.AreEqual("div", result[3].Name);
+ }
- [Test]
- public void Id_Prefix_With_Digit()
- {
- var result = SelectList("#myDiv :nth-last-child(2)");
+ [Test]
+ public void Id_Prefix_With_Digit()
+ {
+ var result = SelectList("#myDiv :nth-last-child(2)");
- Assert.AreEqual(2, result.Count);
- Assert.AreEqual("div", result[0].Name);
- Assert.AreEqual("span", result[1].Name);
- }
+ Assert.AreEqual(2, result.Count);
+ Assert.AreEqual("div", result[0].Name);
+ Assert.AreEqual("span", result[1].Name);
+ }
- [Test]
- public void Element_Prefix_With_Digit()
- {
- var result = SelectList("span:nth-last-child(3)");
+ [Test]
+ public void Element_Prefix_With_Digit()
+ {
+ var result = SelectList("span:nth-last-child(3)");
- Assert.AreEqual(0, result.Count);
- }
+ Assert.AreEqual(0, result.Count);
+ }
- [Test]
- public void Element_Prefix_With_Digit2()
- {
- var result = SelectList("span:nth-last-child(2)");
+ [Test]
+ public void Element_Prefix_With_Digit2()
+ {
+ var result = SelectList("span:nth-last-child(2)");
- Assert.AreEqual(1, result.Count);
- Assert.AreEqual("span", result[0].Name);
- }
- }
+ Assert.AreEqual(1, result.Count);
+ Assert.AreEqual("span", result[0].Name);
+ }
+ }
}
=======================================
--- /Fizzler.Tests/ParserTests.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler.Tests/ParserTests.cs Wed Oct 6 16:35:37 2010
@@ -484,12 +484,12 @@
throw new NotImplementedException();
}
- public void NthLastChild(int a, int b)
- {
- throw new NotImplementedException();
- }
+ public void NthLastChild(int a, int b)
+ {
+ throw new NotImplementedException();
+ }
- #endregion
+ #endregion
}
}
}
=======================================
--- /Fizzler.Tests/SelectorGeneratorTeeTests.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler.Tests/SelectorGeneratorTeeTests.cs Wed Oct 6 16:35:37 2010
@@ -11,374 +11,374 @@
#endregion
/// <summary>
- /// Ensure that all actions on SelectorGeneratorTee are passed
- /// to the internal Primary and Secondary SelectorGenerators.
- /// </summary>
- [TestFixture]
- public class SelectorGeneratorTeeTests
- {
- private static SelectorGeneratorTee tee;
- private static FakeSelectorGenerator primary;
- private static FakeSelectorGenerator secondary;
+ /// Ensure that all actions on SelectorGeneratorTee are passed
+ /// to the internal Primary and Secondary SelectorGenerators.
+ /// </summary>
+ [TestFixture]
+ public class SelectorGeneratorTeeTests
+ {
+ private static SelectorGeneratorTee tee;
+ private static FakeSelectorGenerator primary;
+ private static FakeSelectorGenerator secondary;
- [SetUp]
- public void Setup()
- {
- primary = new FakeSelectorGenerator();
- secondary = new FakeSelectorGenerator();
- tee = new SelectorGeneratorTee(primary, secondary);
- }
+ [SetUp]
+ public void Setup()
+ {
+ primary = new FakeSelectorGenerator();
+ secondary = new FakeSelectorGenerator();
+ tee = new SelectorGeneratorTee(primary, secondary);
+ }
- [Test, ExpectedException(typeof(ArgumentNullException))]
- public void NullPrimary()
- {
- new SelectorGeneratorTee(
- null, new FakeSelectorGenerator()
- );
- }
+ [Test, ExpectedException(typeof(ArgumentNullException))]
+ public void NullPrimary()
+ {
+ new SelectorGeneratorTee(
+ null, new FakeSelectorGenerator()
+ );
+ }
- [Test, ExpectedException(typeof(ArgumentNullException))]
- public void NullSecondary()
- {
- new SelectorGeneratorTee(
- new FakeSelectorGenerator(), null
- );
- }
+ [Test, ExpectedException(typeof(ArgumentNullException))]
+ public void NullSecondary()
+ {
+ new SelectorGeneratorTee(
+ new FakeSelectorGenerator(), null
+ );
+ }
[Test]
- public void OnInitTest()
- {
- Run(tee.OnInit);
- }
+ public void OnInitTest()
+ {
+ Run(tee.OnInit);
+ }
- [Test]
- public void OnCloseTest()
- {
- Run(tee.OnClose);
- }
+ [Test]
+ public void OnCloseTest()
+ {
+ Run(tee.OnClose);
+ }
- [Test]
- public void OnSelectorTest()
- {
- Run(tee.OnSelector);
- }
+ [Test]
+ public void OnSelectorTest()
+ {
+ Run(tee.OnSelector);
+ }
- [Test]
- public void TypeTest()
- {
+ [Test]
+ public void TypeTest()
+ {
Run(tee.Type, NamespacePrefix.None, "go");
- }
+ }
- [Test]
- public void UniversalTest()
- {
- Run(tee.Universal, NamespacePrefix.None);
- }
+ [Test]
+ public void UniversalTest()
+ {
+ Run(tee.Universal, NamespacePrefix.None);
+ }
- [Test]
- public void IdTest()
- {
- Run(tee.Id, "hello");
- }
+ [Test]
+ public void IdTest()
+ {
+ Run(tee.Id, "hello");
+ }
- [Test]
- public void ClassTest()
- {
- Run(tee.Class, "hello");
- }
+ [Test]
+ public void ClassTest()
+ {
+ Run(tee.Class, "hello");
+ }
- [Test]
- public void AttrExistsTest()
- {
- Run(tee.AttributeExists, NamespacePrefix.None, "hello");
- }
+ [Test]
+ public void AttrExistsTest()
+ {
+ Run(tee.AttributeExists, NamespacePrefix.None, "hello");
+ }
- [Test]
- public void AttExactTest()
- {
- Run(tee.AttributeExact, NamespacePrefix.None, "hello", "there");
- }
+ [Test]
+ public void AttExactTest()
+ {
+ Run(tee.AttributeExact,
NamespacePrefix.None, "hello", "there");
+ }
- [Test]
- public void AttrIncludesTest()
- {
- Run(tee.AttributeIncludes, NamespacePrefix.None, "hello", "there");
- }
+ [Test]
+ public void AttrIncludesTest()
+ {
+ Run(tee.AttributeIncludes,
NamespacePrefix.None, "hello", "there");
+ }
- [Test]
- public void AttrDashMatchTest()
- {
- Run(tee.AttributeDashMatch, NamespacePrefix.None, "hello", "there");
- }
+ [Test]
+ public void AttrDashMatchTest()
+ {
+ Run(tee.AttributeDashMatch,
NamespacePrefix.None, "hello", "there");
+ }
- [Test]
- public void AttrPrefixMatchTest()
- {
- Run(tee.AttributePrefixMatch,NamespacePrefix.None, "hello", "there");
- }
+ [Test]
+ public void AttrPrefixMatchTest()
+ {
+
Run(tee.AttributePrefixMatch,NamespacePrefix.None, "hello", "there");
+ }
- [Test]
- public void AttrSuffixMatchTest()
- {
- Run(tee.AttributeSuffixMatch, NamespacePrefix.None, "hello", "there");
- }
+ [Test]
+ public void AttrSuffixMatchTest()
+ {
+ Run(tee.AttributeSuffixMatch,
NamespacePrefix.None, "hello", "there");
+ }
- [Test]
- public void AttrSubstringTest()
- {
- Run(tee.AttributeSubstring, NamespacePrefix.None, "hello", "there");
- }
+ [Test]
+ public void AttrSubstringTest()
+ {
+ Run(tee.AttributeSubstring,
NamespacePrefix.None, "hello", "there");
+ }
- [Test]
- public void FirstChildTest()
- {
- Run(tee.FirstChild);
- }
+ [Test]
+ public void FirstChildTest()
+ {
+ Run(tee.FirstChild);
+ }
- [Test]
- public void LastChildTest()
- {
- Run(tee.LastChild);
- }
+ [Test]
+ public void LastChildTest()
+ {
+ Run(tee.LastChild);
+ }
- [Test]
- public void NthChildTest()
- {
- Run(tee.NthChild, 1, 2);
- }
+ [Test]
+ public void NthChildTest()
+ {
+ Run(tee.NthChild, 1, 2);
+ }
- [Test]
- public void OnlyChildTest()
- {
- Run(tee.OnlyChild);
- }
+ [Test]
+ public void OnlyChildTest()
+ {
+ Run(tee.OnlyChild);
+ }
- [Test]
- public void EmptyTest()
- {
- Run(tee.Empty);
- }
+ [Test]
+ public void EmptyTest()
+ {
+ Run(tee.Empty);
+ }
- [Test]
- public void ChildTest()
- {
- Run(tee.Child);
- }
+ [Test]
+ public void ChildTest()
+ {
+ Run(tee.Child);
+ }
- [Test]
- public void DescendantTest()
- {
- Run(tee.Descendant);
- }
+ [Test]
+ public void DescendantTest()
+ {
+ Run(tee.Descendant);
+ }
- [Test]
- public void AdjacentTest()
- {
- Run(tee.Adjacent);
- }
+ [Test]
+ public void AdjacentTest()
+ {
+ Run(tee.Adjacent);
+ }
- [Test]
- public void GeneralSiblingTest()
- {
- Run(tee.GeneralSibling);
- }
+ [Test]
+ public void GeneralSiblingTest()
+ {
+ Run(tee.GeneralSibling);
+ }
- private static void Run(Action action)
- {
- RunImpl(action.Method);
- }
+ private static void Run(Action action)
+ {
+ RunImpl(action.Method);
+ }
private static void Run<T>(Action<T> action, T arg)
- {
- RunImpl(action.Method, arg);
- }
+ {
+ RunImpl(action.Method, arg);
+ }
- private static void Run<T1, T2>(Action<T1, T2> action, T1 arg1, T2 arg2)
- {
- RunImpl(action.Method, arg1, arg2);
- }
+ private static void Run<T1, T2>(Action<T1, T2> action, T1 arg1, T2
arg2)
+ {
+ RunImpl(action.Method, arg1, arg2);
+ }
private static void Run<T1, T2, T3>(Action<T1, T2, T3> action, T1
arg1, T2 arg2, T3 arg3)
{
RunImpl(action.Method, arg1, arg2, arg3);
}
- /// <summary>
- /// Take the passed action, run it, and then check that the last
method
- /// and last args are the same for pri and sec.
- /// </summary>
- private static void RunImpl(MethodBase action, params object[] args)
- {
+ /// <summary>
+ /// Take the passed action, run it, and then check that the last
method
+ /// and last args are the same for pri and sec.
+ /// </summary>
+ private static void RunImpl(MethodBase action, params object[]
args)
+ {
var recordings = new
Queue<CallRecording<ISelectorGenerator>>(2);
- primary.Recorder = recordings.Enqueue;
- secondary.Recorder = recordings.Enqueue;
+ primary.Recorder = recordings.Enqueue;
+ secondary.Recorder = recordings.Enqueue;
- action.Invoke(tee, args);
+ action.Invoke(tee, args);
- // Assert the fact that the primary and secondary methods were
- // both called with the same arguments and in the right order!
+ // Assert the fact that the primary and secondary methods were
+ // both called with the same arguments and in the right order!
- var recording = recordings.Dequeue();
- Assert.AreSame(primary, recording.Target);
- Assert.AreEqual(action.Name,
MapMethod<ISelectorGenerator>(recording.Method).Name);
- Assert.AreEqual(args, recording.Arguments);
+ var recording = recordings.Dequeue();
+ Assert.AreSame(primary, recording.Target);
+ Assert.AreEqual(action.Name,
MapMethod<ISelectorGenerator>(recording.Method).Name);
+ Assert.AreEqual(args, recording.Arguments);
- recording = recordings.Dequeue();
- Assert.AreSame(secondary, recording.Target);
- Assert.AreEqual(action.Name,
MapMethod<ISelectorGenerator>(recording.Method).Name);
- Assert.AreEqual(args, recording.Arguments);
- }
+ recording = recordings.Dequeue();
+ Assert.AreSame(secondary, recording.Target);
+ Assert.AreEqual(action.Name,
MapMethod<ISelectorGenerator>(recording.Method).Name);
+ Assert.AreEqual(args, recording.Arguments);
+ }
- private static MethodInfo MapMethod<T>(MethodInfo method) where T :
class
- {
- var mapping = method.ReflectedType.GetInterfaceMap(typeof(T));
- return mapping.InterfaceMethods
- .Select((m, i) => new { Source = m, Target =
mapping.TargetMethods[i] })
- .Single(m => m.Target == method).Source;
- }
+ private static MethodInfo MapMethod<T>(MethodInfo method) where
T : class
+ {
+ var mapping = method.ReflectedType.GetInterfaceMap(typeof(T));
+ return mapping.InterfaceMethods
+ .Select((m, i) => new { Source = m, Target =
mapping.TargetMethods[i] })
+ .Single(m => m.Target == method).Source;
+ }
- private sealed class CallRecording<T>
- {
- public T Target { get; private set; }
- public MethodInfo Method { get; private set; }
- public object[] Arguments { get; private set; }
+ private sealed class CallRecording<T>
+ {
+ public T Target { get; private set; }
+ public MethodInfo Method { get; private set; }
+ public object[] Arguments { get; private set; }
- public CallRecording(T target, MethodInfo method, object[]
arguments)
- {
- Target = target;
- Method = method;
- Arguments = arguments;
- }
- }
+ public CallRecording(T target, MethodInfo method, object[]
arguments)
+ {
+ Target = target;
+ Method = method;
+ Arguments = arguments;
+ }
+ }
- private sealed class FakeSelectorGenerator : ISelectorGenerator
- {
+ private sealed class FakeSelectorGenerator : ISelectorGenerator
+ {
public Action<CallRecording<ISelectorGenerator>> Recorder;
- public void OnInit()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void OnInit()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void OnClose()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void OnClose()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void OnSelector()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void OnSelector()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void Type(NamespacePrefix prefix, string type)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), prefix, type);
- }
+ public void Type(NamespacePrefix prefix, string type)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), prefix, type);
+ }
- public void Universal(NamespacePrefix prefix)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), prefix);
- }
+ public void Universal(NamespacePrefix prefix)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), prefix);
+ }
- public void Id(string id)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), id);
- }
+ public void Id(string id)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), id);
+ }
- public void Class(string clazz)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), clazz);
- }
+ public void Class(string clazz)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), clazz);
+ }
- public void AttributeExists(NamespacePrefix prefix, string name)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), prefix, name);
- }
+ public void AttributeExists(NamespacePrefix prefix, string
name)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), prefix, name);
+ }
- public void AttributeExact(NamespacePrefix prefix, string name,
string value)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), prefix, name, value);
- }
+ public void AttributeExact(NamespacePrefix prefix, string
name, string value)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), prefix, name,
value);
+ }
- public void AttributeIncludes(NamespacePrefix prefix, string
name, string value)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), prefix, name, value);
- }
+ public void AttributeIncludes(NamespacePrefix prefix, string
name, string value)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), prefix, name,
value);
+ }
- public void AttributeDashMatch(NamespacePrefix prefix, string
name, string value)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), prefix, name, value);
- }
+ public void AttributeDashMatch(NamespacePrefix prefix, string
name, string value)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), prefix, name,
value);
+ }
- public void AttributePrefixMatch(NamespacePrefix prefix, string
name, string value)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), prefix, name, value);
- }
+ public void AttributePrefixMatch(NamespacePrefix prefix,
string name, string value)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), prefix, name,
value);
+ }
- public void AttributeSuffixMatch(NamespacePrefix prefix, string
name, string value)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), prefix, name, value);
- }
+ public void AttributeSuffixMatch(NamespacePrefix prefix,
string name, string value)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), prefix, name,
value);
+ }
- public void AttributeSubstring(NamespacePrefix prefix, string
name, string value)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), prefix, name, value);
- }
+ public void AttributeSubstring(NamespacePrefix prefix, string
name, string value)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), prefix, name,
value);
+ }
- public void FirstChild()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void FirstChild()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void LastChild()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void LastChild()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void NthChild(int a, int b)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), a,b);
- }
+ public void NthChild(int a, int b)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), a, b);
+ }
- public void OnlyChild()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void OnlyChild()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void Empty()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void Empty()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void Child()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void Child()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void Descendant()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void Descendant()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void Adjacent()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void Adjacent()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void GeneralSibling()
- {
- OnInvoked(MethodBase.GetCurrentMethod());
- }
+ public void GeneralSibling()
+ {
+ OnInvoked(MethodBase.GetCurrentMethod());
+ }
- public void NthLastChild(int a, int b)
- {
- OnInvoked(MethodBase.GetCurrentMethod(), a, b);
- }
+ public void NthLastChild(int a, int b)
+ {
+ OnInvoked(MethodBase.GetCurrentMethod(), a, b);
+ }
- private void OnInvoked(MethodBase method, params object[] args)
- {
- Recorder(new CallRecording<ISelectorGenerator>(this,
(MethodInfo) method, args));
- }
- }
- }
+ private void OnInvoked(MethodBase method, params object[] args)
+ {
+ Recorder(new CallRecording<ISelectorGenerator>(this,
(MethodInfo) method, args));
+ }
+ }
+ }
}
=======================================
--- /Fizzler/HumanReadableSelectorGenerator.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler/HumanReadableSelectorGenerator.cs Wed Oct 6 16:35:37 2010
@@ -2,239 +2,239 @@
{
using System;
- /// <summary>
+ /// <summary>
/// An <see cref="ISelectorGenerator"/> implementation that generates
/// human-readable description of the selector.
- /// </summary>
- public class HumanReadableSelectorGenerator : ISelectorGenerator
- {
- private int _chainCount;
+ /// </summary>
+ public class HumanReadableSelectorGenerator : ISelectorGenerator
+ {
+ private int _chainCount;
private string _text;
/// <summary>
/// Initializes the text.
/// </summary>
public virtual void OnInit()
- {
- Text = null;
- }
+ {
+ Text = null;
+ }
- /// <summary>
- /// Gets the generated human-readable description text.
- /// </summary>
- public string Text
- {
- get { return _text; }
- private set { _text = value; }
- }
+ /// <summary>
+ /// Gets the generated human-readable description text.
+ /// </summary>
+ public string Text
+ {
+ get { return _text; }
+ private set { _text = value; }
+ }
/// <summary>
/// Generates human-readable for a selector in a group.
/// </summary>
public virtual void OnSelector()
- {
- if (string.IsNullOrEmpty(Text))
- Text = "Take all";
- else
- Text += " and select them. Combined with previous, take all";
- }
+ {
+ if (string.IsNullOrEmpty(Text))
+ Text = "Take all";
+ else
+ Text += " and select them. Combined with previous, take
all";
+ }
- /// <summary>
- /// Concludes the text.
- /// </summary>
- public virtual void OnClose()
- {
- Text = Text.Trim();
- Text += " and select them.";
- }
+ /// <summary>
+ /// Concludes the text.
+ /// </summary>
+ public virtual void OnClose()
+ {
+ Text = Text.Trim();
+ Text += " and select them.";
+ }
- /// <summary>
- /// Adds to the generated human-readable text.
- /// </summary>
- protected void Add(string selector)
- {
- if (selector == null) throw new ArgumentNullException("selector");
- Text += selector;
- }
+ /// <summary>
+ /// Adds to the generated human-readable text.
+ /// </summary>
+ protected void Add(string selector)
+ {
+ if (selector == null) throw new
ArgumentNullException("selector");
+ Text += selector;
+ }
/// <summary>
/// Generates human-readable text of this type selector.
/// </summary>
public void Type(NamespacePrefix prefix, string type)
- {
- Add(string.Format(" <{0}> elements", type));
- }
+ {
+ Add(string.Format(" <{0}> elements", type));
+ }
/// <summary>
/// Generates human-readable text of this universal selector.
/// </summary>
public void Universal(NamespacePrefix prefix)
- {
- Add(" elements");
- }
+ {
+ Add(" elements");
+ }
/// <summary>
/// Generates human-readable text of this ID selector.
/// </summary>
public void Id(string id)
- {
- Add(string.Format(" with an ID of '{0}'", id));
- }
+ {
+ Add(string.Format(" with an ID of '{0}'", id));
+ }
/// <summary>
/// Generates human-readable text of this class selector.
/// </summary>
void ISelectorGenerator.Class(string clazz)
- {
- Add(string.Format(" with a class of '{0}'", clazz));
- }
+ {
+ Add(string.Format(" with a class of '{0}'", clazz));
+ }
/// <summary>
/// Generates human-readable text of this attribute selector.
/// </summary>
public void AttributeExists(NamespacePrefix prefix, string name)
- {
+ {
Add(string.Format(" which have attribute {0} defined", name));
- }
+ }
/// <summary>
/// Generates human-readable text of this attribute selector.
/// </summary>
public void AttributeExact(NamespacePrefix prefix, string name,
string value)
- {
- Add(string.Format(" which have attribute {0} with a value of '{1}'",
name, value));
- }
+ {
+ Add(string.Format(" which have attribute {0} with a value
of '{1}'", name, value));
+ }
/// <summary>
/// Generates human-readable text of this attribute selector.
/// </summary>
public void AttributeIncludes(NamespacePrefix prefix, string name,
string value)
- {
- Add(string.Format(" which have attribute {0} that includes the
word '{1}'", name, value));
- }
+ {
+ Add(string.Format(" which have attribute {0} that includes the
word '{1}'", name, value));
+ }
/// <summary>
/// Generates human-readable text of this attribute selector.
/// </summary>
public void AttributeDashMatch(NamespacePrefix prefix, string
name, string value)
- {
- Add(string.Format(" which have attribute {0} with a hyphen separated
value matching '{1}'", name, value));
- }
+ {
+ Add(string.Format(" which have attribute {0} with a hyphen
separated value matching '{1}'", name, value));
+ }
/// <summary>
/// Generates human-readable text of this attribute selector.
/// </summary>
public void AttributePrefixMatch(NamespacePrefix prefix, string
name, string value)
- {
- Add(string.Format(" which have attribute {0} whose value begins
with '{1}'", name, value));
+ {
+ Add(string.Format(" which have attribute {0} whose value
begins with '{1}'", name, value));
}
/// <summary>
/// Generates human-readable text of this attribute selector.
/// </summary>
public void AttributeSuffixMatch(NamespacePrefix prefix, string
name, string value)
- {
- Add(string.Format(" which have attribute {0} whose value ends
with '{1}'", name, value));
+ {
+ Add(string.Format(" which have attribute {0} whose value ends
with '{1}'", name, value));
}
/// <summary>
/// Generates human-readable text of this attribute selector.
/// </summary>
public void AttributeSubstring(NamespacePrefix prefix, string
name, string value)
- {
- Add(string.Format(" which have attribute {0} whose value
contains '{1}'", name, value));
+ {
+ Add(string.Format(" which have attribute {0} whose value
contains '{1}'", name, value));
}
/// <summary>
/// Generates human-readable text of this pseudo-class selector.
/// </summary>
public void FirstChild()
- {
- Add(" which are the first child of their parent");
- }
+ {
+ Add(" which are the first child of their parent");
+ }
/// <summary>
/// Generates human-readable text of this pseudo-class selector.
/// </summary>
public void LastChild()
- {
- Add(" which are the last child of their parent");
- }
+ {
+ Add(" which are the last child of their parent");
+ }
/// <summary>
/// Generates human-readable text of this pseudo-class selector.
/// </summary>
public void NthChild(int a, int b)
- {
- Add(string.Format(" where the element has {0}n+{1}-1 sibling before
it", a, b));
- }
+ {
+ Add(string.Format(" where the element has {0}n+{1}-1 sibling
before it", a, b));
+ }
/// <summary>
/// Generates human-readable text of this pseudo-class selector.
/// </summary>
public void OnlyChild()
- {
- Add(" where the element is the only child");
- }
+ {
+ Add(" where the element is the only child");
+ }
/// <summary>
/// Generates human-readable text of this pseudo-class selector.
/// </summary>
public void Empty()
- {
- Add(" where the element is empty");
- }
+ {
+ Add(" where the element is empty");
+ }
/// <summary>
/// Generates human-readable text of this combinator.
/// </summary>
public void Child()
- {
- Add(", then take their immediate children which are");
- }
+ {
+ Add(", then take their immediate children which are");
+ }
/// <summary>
/// Generates human-readable text of this combinator.
/// </summary>
public void Descendant()
- {
- if (_chainCount > 0)
- {
- Add(". With those, take only their descendants which are");
- }
- else
- {
- Add(", then take their descendants which are");
- _chainCount++;
- }
- }
+ {
+ if (_chainCount > 0)
+ {
+ Add(". With those, take only their descendants which are");
+ }
+ else
+ {
+ Add(", then take their descendants which are");
+ _chainCount++;
+ }
+ }
/// <summary>
/// Generates human-readable text of this combinator.
/// </summary>
public void Adjacent()
- {
- Add(", then take their immediate siblings which are");
- }
+ {
+ Add(", then take their immediate siblings which are");
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
- /// which separates two sequences of simple selectors. The elements
represented
- /// by the two sequences share the same parent in the document tree and
the
- /// element represented by the first sequence precedes (not necessarily
- /// immediately) the element represented by the second one.
- /// </summary>
- public void GeneralSibling()
- {
- Add(", then take their siblings which are");
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
+ /// which separates two sequences of simple selectors. The
elements represented
+ /// by the two sequences share the same parent in the document
tree and the
+ /// element represented by the first sequence precedes (not
necessarily
+ /// immediately) the element represented by the second one.
+ /// </summary>
+ public void GeneralSibling()
+ {
+ Add(", then take their siblings which are");
+ }
- /// <summary>
- /// Generates human-readable text of this combinator.
- /// </summary>
- public void NthLastChild(int a, int b)
- {
- Add(string.Format(" where the element has {0}n+{1}-1 sibling after it",
a, b));
- }
- }
+ /// <summary>
+ /// Generates human-readable text of this combinator.
+ /// </summary>
+ public void NthLastChild(int a, int b)
+ {
+ Add(string.Format(" where the element has {0}n+{1}-1 sibling
after it", a, b));
+ }
+ }
}
=======================================
--- /Fizzler/ISelectorGenerator.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler/ISelectorGenerator.cs Wed Oct 6 16:35:37 2010
@@ -167,19 +167,19 @@
/// </summary>
void Adjacent();
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
- /// which separates two sequences of simple selectors. The elements
represented
- /// by the two sequences share the same parent in the document tree and
the
- /// element represented by the first sequence precedes (not necessarily
- /// immediately) the element represented by the second one.
- /// </summary>
- void GeneralSibling();
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
+ /// which separates two sequences of simple selectors. The
elements represented
+ /// by the two sequences share the same parent in the document
tree and the
+ /// element represented by the first sequence precedes (not
necessarily
+ /// immediately) the element represented by the second one.
+ /// </summary>
+ void GeneralSibling();
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
- /// which represents an element that is the N-th child from bottom up of
some other element.
- /// </summary>
- void NthLastChild(int a, int b);
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child from bottom
up of some other element.
+ /// </summary>
+ void NthLastChild(int a, int b);
}
}
=======================================
--- /Fizzler/Parser.cs Wed Oct 6 16:28:04 2010
+++ /Fizzler/Parser.cs Wed Oct 6 16:35:37 2010
@@ -19,7 +19,7 @@
{
private readonly Reader<Token> _reader;
private readonly ISelectorGenerator _generator;
-
+
private Parser(Reader<Token> reader, ISelectorGenerator generator)
{
Debug.Assert(reader != null);
@@ -45,7 +45,7 @@
{
if (selectors == null) throw new
ArgumentNullException("selectors");
if (selectors.Length == 0) throw new
ArgumentException(null, "selectors");
-
+
return Parse(Tokener.Tokenize(selectors), generator, resultor);
}
@@ -53,7 +53,7 @@
/// Parses a tokenized stream representing a CSS selector group and
/// generates its implementation.
/// </summary>
- public static TGenerator Parse<TGenerator>(IEnumerable<Token>
tokens, TGenerator generator)
+ public static TGenerator Parse<TGenerator>(IEnumerable<Token>
tokens, TGenerator generator)
where TGenerator : ISelectorGenerator
{
return Parse(tokens, generator, g => g);
@@ -63,12 +63,12 @@
/// Parses a tokenized stream representing a CSS selector group and
/// generates its implementation.
/// </summary>
- public static T Parse<TGenerator, T>(IEnumerable<Token> tokens,
TGenerator generator, Func<TGenerator, T> resultor)
+ public static T Parse<TGenerator, T>(IEnumerable<Token> tokens,
TGenerator generator, Func<TGenerator, T> resultor)
where TGenerator : ISelectorGenerator
{
if (tokens == null) throw new ArgumentNullException("tokens");
- if(resultor == null) throw new
ArgumentNullException("resultor");
-
+ if (resultor == null) throw new
ArgumentNullException("resultor");
+
new Parser(new Reader<Token>(tokens.GetEnumerator()),
generator).Parse();
return resultor(generator);
}
@@ -117,7 +117,7 @@
// ;
var token = TryRead(ToTokenSpec(TokenKind.Plus),
ToTokenSpec(TokenKind.Greater), ToTokenSpec(TokenKind.Tilde),
ToTokenSpec(TokenKind.WhiteSpace));
-
+
if (token == null)
return false;
@@ -136,7 +136,7 @@
TryRead(ToTokenSpec(TokenKind.WhiteSpace));
}
-
+
return true;
}
@@ -162,9 +162,9 @@
}
else
{
- if (modifiers == 0 && !named)
+ if (modifiers == 0 && !named)
_generator.Universal(NamespacePrefix.None); //
implied
-
+
if (token.Value.Kind == TokenKind.Hash)
{
_generator.Id(token.Value.Text);
@@ -214,10 +214,10 @@
case "only-child": _generator.OnlyChild(); break;
case "empty": _generator.Empty(); break;
default:
- {
- throw new FormatException(string.Format(
- "Unknown pseudo-class '{0}'. Use either
first-child, last-child, only-child or empty.", clazz));
- }
+ {
+ throw new FormatException(string.Format(
+ "Unknown pseudo-class '{0}'. Use either
first-child, last-child, only-child or empty.", clazz));
+ }
}
}
}
@@ -238,12 +238,12 @@
switch (func)
{
case "nth-child": Nth(); break;
- case "nth-last-child": NthLast(); break;
+ case "nth-last-child": NthLast(); break;
default:
- {
- throw new FormatException(string.Format(
- "Unknown functional pseudo '{0}'. Only nth-child
and nth-last-child are supported.", func));
- }
+ {
+ throw new FormatException(string.Format(
+ "Unknown functional pseudo '{0}'. Only
nth-child and nth-last-child are supported.", func));
+ }
}
Read(ToTokenSpec(Token.RightParenthesis()));
@@ -264,17 +264,17 @@
}
private void NthLast()
- {
- //nth
- // : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
- // ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
- // ;
+ {
+ //nth
+ // : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER
]? |
+ // ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
+ // ;
- // TODO Add support for the full syntax
- // At present, only INTEGER is allowed
+ // TODO Add support for the full syntax
+ // At present, only INTEGER is allowed
- _generator.NthLastChild(1, NthB());
- }
+ _generator.NthLastChild(1, NthB());
+ }
private int NthB()
{
@@ -297,21 +297,21 @@
Read(ToTokenSpec(Token.LeftBracket()));
var prefix = TryNamespacePrefix() ?? NamespacePrefix.None;
var name = Read(ToTokenSpec(TokenKind.Ident)).Text;
-
+
var hasValue = false;
while (true)
{
var op = TryRead(
- ToTokenSpec(Token.Equals()),
- ToTokenSpec(TokenKind.Includes),
- ToTokenSpec(TokenKind.DashMatch),
- ToTokenSpec(TokenKind.PrefixMatch),
+ ToTokenSpec(Token.Equals()),
+ ToTokenSpec(TokenKind.Includes),
+ ToTokenSpec(TokenKind.DashMatch),
+ ToTokenSpec(TokenKind.PrefixMatch),
ToTokenSpec(TokenKind.SuffixMatch),
ToTokenSpec(TokenKind.SubstringMatch));
-
- if(op == null)
+
+ if (op == null)
break;
-
+
hasValue = true;
var value = Read(ToTokenSpec(TokenKind.String),
ToTokenSpec(TokenKind.Ident)).Text;
@@ -331,10 +331,10 @@
}
}
}
-
+
if (!hasValue)
_generator.AttributeExists(prefix, name);
-
+
Read(ToTokenSpec(Token.RightBracket()));
}
@@ -343,7 +343,7 @@
//class
// : '.' IDENT
// ;
-
+
Read(ToTokenSpec(Token.Dot()));
_generator.Class(Read(ToTokenSpec(TokenKind.Ident)).Text);
}
@@ -356,20 +356,20 @@
var pipe = Token.Pipe();
var token = TryRead(ToTokenSpec(TokenKind.Ident),
ToTokenSpec(Token.Star()), ToTokenSpec(pipe));
-
+
if (token == null)
return null;
-
+
if (token.Value == pipe)
return NamespacePrefix.Empty;
-
+
var prefix = token.Value;
if (TryRead(ToTokenSpec(pipe)) == null)
{
Unread(prefix);
return null;
}
-
+
return prefix.Kind == TokenKind.Ident
? new NamespacePrefix(prefix.Text)
: NamespacePrefix.Any;
@@ -418,7 +418,7 @@
if (token == null)
{
throw new FormatException(string.Format(
- @"Unexpected token {{{0}}} where one of [{1}] was
expected.",
+ @"Unexpected token {{{0}}} where one of [{1}] was
expected.",
Peek().Kind, string.Join(", ", specs.Select(k =>
k.ToString()).ToArray())));
}
return token.Value;
=======================================
--- /Fizzler/SelectorGenerator.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler/SelectorGenerator.cs Wed Oct 6 16:35:37 2010
@@ -296,25 +296,25 @@
Add(Ops.Adjacent());
}
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
- /// which separates two sequences of simple selectors. The elements
represented
- /// by the two sequences share the same parent in the document tree and
the
- /// element represented by the first sequence precedes (not necessarily
- /// immediately) the element represented by the second one.
- /// </summary>
- public virtual void GeneralSibling()
- {
- Add(Ops.GeneralSibling());
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>,
+ /// which separates two sequences of simple selectors. The
elements represented
+ /// by the two sequences share the same parent in the document
tree and the
+ /// element represented by the first sequence precedes (not
necessarily
+ /// immediately) the element represented by the second one.
+ /// </summary>
+ public virtual void GeneralSibling()
+ {
+ Add(Ops.GeneralSibling());
+ }
- /// <summary>
- /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
- /// which represents an element that is the N-th child from bottom up of
some other element.
- /// </summary>
- public void NthLastChild(int a, int b)
- {
- Add(Ops.NthLastChild(a, b));
- }
+ /// <summary>
+ /// Generates a <a
href="
http://www.w3.org/TR/css3-selectors/#pseudo-classes">pseudo-class
selector</a>,
+ /// which represents an element that is the N-th child from bottom
up of some other element.
+ /// </summary>
+ public void NthLastChild(int a, int b)
+ {
+ Add(Ops.NthLastChild(a, b));
+ }
}
}
=======================================
--- /Fizzler/SelectorGeneratorTee.cs Wed Oct 6 16:15:18 2010
+++ /Fizzler/SelectorGeneratorTee.cs Wed Oct 6 16:35:37 2010
@@ -231,22 +231,22 @@
Secondary.Adjacent();
}
- /// <summary>
- /// Delegates to <see cref="Primary"/> then <see cref="Secondary"/>
generator.
- /// </summary>
- public void GeneralSibling()
- {
- Primary.GeneralSibling();
- Secondary.GeneralSibling();
- }
+ /// <summary>
+ /// Delegates to <see cref="Primary"/> then <see
cref="Secondary"/> generator.
+ /// </summary>
+ public void GeneralSibling()
+ {
+ Primary.GeneralSibling();
+ Secondary.GeneralSibling();
+ }
- /// <summary>
- /// Delegates to <see cref="Primary"/> then <see cref="Secondary"/>
generator.
- /// </summary>
- public void NthLastChild(int a, int b)
- {
- Primary.NthLastChild(a, b);
- Secondary.NthLastChild(a, b);
- }
+ /// <summary>
+ /// Delegates to <see cref="Primary"/> then <see
cref="Secondary"/> generator.
+ /// </summary>
+ public void NthLastChild(int a, int b)
+ {
+ Primary.NthLastChild(a, b);
+ Secondary.NthLastChild(a, b);
+ }
}
}
==============================================================================
Revision: 854aa970f9cc
Branch: default
Author: azizatif
Date: Wed Oct 6 16:42:39 2010
Log: Fixed typos in exception messages.
http://code.google.com/p/fizzler/source/detail?r=854aa970f9cc
Modified:
/Fizzler.Sandbox/Xml/XmlNodeOps.cs
/Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs
=======================================
--- /Fizzler.Sandbox/Xml/XmlNodeOps.cs Wed Oct 6 16:35:37 2010
+++ /Fizzler.Sandbox/Xml/XmlNodeOps.cs Wed Oct 6 16:42:39 2010
@@ -122,7 +122,7 @@
public virtual Selector<XmlNode> NthChild(int a, int b)
{
if (a != 1)
- throw new NotSupportedException("The nth-child(an+b)
selector where a in is not 1 are not supported.");
+ throw new NotSupportedException("The nth-child(an+b)
selector where a is not 1 is not supported.");
return nodes => from n in nodes
let elements =
n.ParentNode.Elements().Take(b).ToArray()
@@ -198,7 +198,7 @@
public Selector<XmlNode> NthLastChild(int a, int b)
{
if (a != 1)
- throw new NotSupportedException("The nth-last-child(an+b)
selector where a in is not 1 are not supported.");
+ throw new NotSupportedException("The nth-last-child(an+b)
selector where a is not 1 is not supported.");
return nodes => from n in nodes
let elements =
n.ParentNode.Elements().Skip(Math.Max(0, n.ParentNode.Elements().Count() -
b)).Take(b).ToArray()
=======================================
--- /Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs Wed Oct 6 16:35:37 2010
+++ /Fizzler.Systems.HtmlAgilityPack/HtmlNodeOps.cs Wed Oct 6 16:42:39 2010
@@ -190,7 +190,7 @@
public virtual Selector<HtmlNode> NthChild(int a, int b)
{
if (a != 1)
- throw new NotSupportedException("The nth-child(an+b)
selector where a in is not 1 are not supported.");
+ throw new NotSupportedException("The nth-child(an+b)
selector where a is not 1 is not supported.");
return nodes => from n in nodes
let elements =
n.ParentNode.Elements().Take(b).ToArray()
@@ -266,7 +266,7 @@
public Selector<HtmlNode> NthLastChild(int a, int b)
{
if (a != 1)
- throw new NotSupportedException("The nth-last-child(an+b)
selector where a in is not 1 are not supported.");
+ throw new NotSupportedException("The nth-last-child(an+b)
selector where a is not 1 is not supported.");
return nodes => from n in nodes
let elements =
n.ParentNode.Elements().Skip(Math.Max(0, n.ParentNode.Elements().Count() -
b)).Take(b).ToArray()
==============================================================================
Revision: 41f2faaf12bc
Branch: default
Author: convert-repo
Date: Thu Jan 3 14:27:26 2013
Log: update tags
http://code.google.com/p/fizzler/source/detail?r=41f2faaf12bc
Added:
/.hgtags
=======================================
--- /dev/null
+++ /.hgtags Thu Jan 3 14:27:26 2013
@@ -0,0 +1,1 @@
+2a56e44be0b6c32283f9181e62decda38cf92c59 0.9