|
using System;
using System.Collections.Generic;
using System.Text;
namespace Zadesoft.Library.Script.Functions
{
class BuiltInFunctions
: IFunctionExecutor
{
private static BuiltInFunctions _current = new BuiltInFunctions();
public static IFunctionExecutor Current
{
get
{
return _current;
}
}
private Dictionary<string, IFunction> _functions;
protected BuiltInFunctions()
{
_functions = new Dictionary<string, IFunction>();
Init();
}
private void Init()
{
IFunction fn = new IsTodayFunction();
_functions.Add(fn.Name, fn);
fn = new IsBeforeTodayFunction();
_functions.Add(fn.Name, fn);
fn = new IsAfterTodayFunction();
_functions.Add(fn.Name, fn);
fn = new IsNullOrEmptyFunction();
_functions.Add(fn.Name, fn);
fn = new DoesMatchRegexFunction();
_functions.Add(fn.Name, fn);
fn = new DoesContainWordFunction();
_functions.Add(fn.Name, fn);
}
public void Register(IFunction fn)
{
if (fn != null)
{
if (_functions.ContainsKey(fn.Name))
{
_functions[fn.Name] = fn;
}
else
{
_functions.Add(fn.Name, fn);
}
}
}
#region IExternalFunctionExecutor Members
public bool Contains(string fnName)
{
return _functions.ContainsKey(fnName);
}
public object Execute(string fnName, params object[] paras)
{
if (_functions.ContainsKey(fnName))
{
return _functions[fnName].Execute(paras);
}
else
{
throw new ExpressionException("no such function found in built in functions");
}
}
#endregion
#region IRuntimePortal Members
public string Name
{
get { return "BuiltInFunctions"; }
}
#endregion
}
}
|
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...