|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Irony.Compiler;
using Irony.Runtime;
using WWWDSL;
using System.IO;
namespace testwwwdsl
{
class Program
{
static private void ProgressChange(object sender, ProgressEventArgs e)
{
if (e.Progress != -1)
{
Console.WriteLine("Action: {0}, Progress:{1}%", e.ActionName, e.Progress);
}
else
{
Console.WriteLine("Action: {0}", e.ActionName);
}
}
static public void LogAction(object sender, LogEventArgs e)
{
Console.WriteLine(e.ActionDesc);
}
static void Main(string[] args)
{
if (args.Length < 2)
{
Console.WriteLine("Usage: testwwwdsl.exe RecipeFile URLsToDownloadFromListFile");
return;
}
LanguageCompiler compiler = new LanguageCompiler(new WwwDSLGrammar());
WwwDslEvaluator wwwDslEval = new WwwDslEvaluator(args[0], compiler);
WwwDslEvaluationContext evalContext = new WwwDslEvaluationContext(wwwDslEval.CompilerContext.Runtime, wwwDslEval.RootNode);
evalContext.GetProcessingContext().ProgressChange += ProgressChange;
evalContext.GetProcessingContext().LogAction += LogAction;
List<string> urls = new List<string>();
using (StreamReader filesListStream = new StreamReader(args[1]))
{
while (!filesListStream.EndOfStream)
{
urls.Add(filesListStream.ReadLine());
}
}
foreach (var url in urls)
{
try
{
wwwDslEval.Process(evalContext, new Dictionary<string, string>() { { "arg1", url }, { "arg2", "c:\\" } });
Console.WriteLine("Processing finished.");
}
catch (Exception e)
{
Console.WriteLine("Processing error:\n" + e.Message);
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.