|
using System;
using System.Collections.Generic;
using System.Text;
using Zadesoft.Library.Script;
using Zadesoft.Library.Script.ExternalValueProviders;
namespace ConsoleTestApp
{
class TestScript
{
public void TestScriptCode()
{
ScriptContext context = new ScriptContext();
DictionaryExternalValueProvider evp = new DictionaryExternalValueProvider();
evp.AddValue("dt", DateTime.Today);
evp.AddValue("dt2", DateTime.Today.AddDays(1));
evp.AddValue("dt3", DateTime.Today.AddDays(-1));
evp.AddValue("v", "abc");
evp.AddValue("regex", @"^\d+$");
evp.AddValue("i", 10);
evp.AddValue("f", 10.5);
context.AddPortal(evp);
ScriptProcessor processor = new ScriptProcessor(context);
try
{
//Console.WriteLine(processor.Evaluate<bool>("IsToday(@dt2) && IsToday(@dt) || DoesMatchRegex(\"38883\", @regex);"));
//Console.WriteLine(processor.Evaluate<bool>("!IsToday(@dt) || IsToday(@dt);"));
//Console.WriteLine(processor.Evaluate<bool>("1 >=2 && IsToday(@dt);"));
//Console.WriteLine(processor.Evaluate<bool>("@i >=20;"));
//Console.WriteLine(processor.Evaluate<bool>("@f >=10.4;"));
//Console.WriteLine(processor.Evaluate<bool>("IsAfterToday(@dt3);"));
//Console.WriteLine(processor.Evaluate<bool>("IsBeforeToday(@dt3);"));
//Console.WriteLine(processor.Evaluate<bool>("DoesContainWord(@v, \"d\");"));
Console.WriteLine(processor.Evaluate<bool>("2!=2 || 1==2;"));
}
catch (Exception e)
{
Console.WriteLine("Exception: " + 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.
Just develop simple softwares. C# is my favorite prgramming languare, though I hope to create a new one...