forked from MikeChristensen/parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parser.cs
48 lines (41 loc) · 1.51 KB
/
Parser.cs
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
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using KitchenPC.Context;
namespace KitchenPC.Parser
{
class Parser
{
static void Main()
{
// Initialize KitchenPC
KPCContext.Initialize(Configuration<StaticContext>.Build
.Context(StaticContext.Configure
.DataDirectory(@"C:\KitchenPC\src\SampleData\")
).Create());
// Initialize Parser Factory
ParserFactory.Initialize(
KPCContext.Current,
typeof(Parsers.hRecipeParser).Assembly,
typeof(Parsers.hRecipeParser));
// Test URIs
var urls = new[]
{
// new Uri("http://allrecipes.com/recipe/classic-peanut-butter-cookies/"),
new Uri("http://www.food.com/recipe/aunt-eileens-sauce-pan-brownies-256306"),
new Uri("http://www.food.com/recipe/lower-fat-banana-nut-chip-muffins-199237"),
new Uri("http://www.food.com/recipe/grated-apple-cinnamon-cake-183836"),
new Uri("http://www.food.com/recipe/buttery-ricotta-cookies-339259")
};
urls.ForEach(u =>
{
var parser = ParserFactory.GetParser(u);
var result = parser.Parse(u);
if (result.Result == ParserResult.Status.Success)
Console.WriteLine("Successfully parsed recipe: {0}", result.Recipe.Title);
else
Console.WriteLine("Could not parse {0}", u);
});
Console.WriteLine("\nDone! [Press Any Key]");
Console.ReadLine();
}
}
}