forked from NancyFx/Nancy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocumentWrapper.cs
More file actions
36 lines (32 loc) · 1.09 KB
/
Copy pathDocumentWrapper.cs
File metadata and controls
36 lines (32 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
namespace Nancy.Testing
{
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CsQuery;
/// <summary>
/// A basic wrapper around CsQuery
/// </summary>
public class DocumentWrapper
{
private readonly CQ document;
/// <summary>
/// Initializes a new instance of the <see cref="DocumentWrapper"/> class.
/// </summary>
/// <param name="buffer">The document represented as a byte array.</param>
public DocumentWrapper(IEnumerable<byte> buffer)
{
var utf8String = Encoding.UTF8.GetString(buffer.ToArray());
this.document = CQ.Create(utf8String);
}
/// <summary>
/// Gets elements from CSS3 selectors
/// </summary>
/// <param name="selector">The CSS3 selector that should be applied.</param>
/// <returns>A <see cref="QueryWrapper"/> instance.</returns>
public QueryWrapper this[string selector]
{
get { return this.document.Select(selector); }
}
}
}