public static void Initialize(TestContext context) { var typeSystemBuilder = new TypeSystemBuilder(); typeSystemBuilder.AddFromScan(typeof(TypeSystemBuilderByAttributesTests)); var typeSystem = typeSystemBuilder.Build(); scope = new EvaluationScope(typeSystem); scope.AddFromScan(typeof(TypeSystemBuilderByAttributesTests)); }
public ViewModel() { FilteredSubjects = new ObservableCollection<Subject>(); var tbuilder = new TypeSystemBuilder(); var SubjectType = tbuilder.AddType<Subject>("Subject", "Object of interest."); SubjectType.AddForeignProperty(IdDelimiter.Dot, "name", sub => sub.Name); SubjectType.AddForeignProperty(IdDelimiter.Dot, "age", sub => sub.Age); SubjectType.AddForeignProperty(IdDelimiter.Dot, "class", sub => sub.Class); var context = new EvaluationScope(tbuilder.Build()); Context = context; Update(); }
public static void SetupFixture(TestContext testContext) { var typeSystemBuilder = new TypeSystemBuilder(); var Ticket = typeSystemBuilder.AddType <Ticket>("Ticket", "Description of Ticket"); Ticket.AddForeignProperty(IdDelimiter.Dot, "id", t => t.Id); Ticket.AddForeignProperty(IdDelimiter.Dot, "owner", t => t.Owner); var typeSystem = typeSystemBuilder.Build(); context = new EvaluationScope(typeSystem); context.DefineForeignGlobalFunction <int, int, int>("max", (a, b) => Math.Max(a, b)); var String = typeSystem.GetTypeByNative <string>(); String.AddForeignFunction(IdDelimiter.Dot, "length", str => str.Length); String.AddForeignFunction <int, string>(IdDelimiter.Dot, "append", (str, index) => str + index); String.AddForeignProperty(IdDelimiter.Dot, "size", str => str.Length); String.AddForeignIndexer <int, string>((str, index) => str[index - 1].ToString()); ticketOne = new Ticket(1, "Markus"); ticketTwo = new Ticket(2, "Jenny"); ticketThree = new Ticket(3, null); }
/// <summary> /// Defines a global function using a lambda function. /// </summary> /// <typeparam name="T1"></typeparam> /// <typeparam name="T2"></typeparam> /// <typeparam name="T3"></typeparam> /// <typeparam name="T4"></typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="this"></param> /// <param name="name"></param> /// <param name="func"></param> /// <returns></returns> public static IVariable <object> DefineForeignGlobalFunction <T1, T2, T3, T4, TResult>(this EvaluationScope @this, string name, Func <T1, T2, T3, T4, TResult> func) { return(@this.DefineVariable(name, new Closure <LambdaGlobalFunction <T1, T2, T3, T4, TResult> >(new LambdaGlobalFunction <T1, T2, T3, T4, TResult>(func)))); }