public void Main()
        {
            IExpression person1  = new TerminalExpression.TerminalExpression("Kushagra");
            IExpression person2  = new TerminalExpression.TerminalExpression("Lokesh");
            IExpression isSingle = new OrExpression(person1, person2);

            IExpression vikram      = new TerminalExpression.TerminalExpression("Vikram");
            IExpression committed   = new TerminalExpression.TerminalExpression("Committed");
            IExpression isCommitted = new AndExpression(vikram, committed);

            Console.WriteLine(isSingle.Interpret("Kushagra"));
            Console.WriteLine(isSingle.Interpret("Lokesh"));
            Console.WriteLine(isSingle.Interpret("Achint"));
            Console.WriteLine(isCommitted.Interpret("Committed, Vikram"));
            Console.WriteLine(isCommitted.Interpret("Single, Vikram"));
        }
Esempio n. 2
0
        public static void TestInterpreterRelationships()
        {
            Console.WriteLine("----------------------Interpreter Relationships----------------------");
            Expr person1  = new Terminal("Tom");
            Expr person2  = new Terminal("Luke");
            Expr isSingle = new OrExpression(person1, person2);

            Expr alice       = new Terminal("Alice");
            Expr committed   = new Terminal("Committed");
            Expr isCommitted = new AndExpression(alice, committed);

            Interpreter.Relationship.Context context = new Interpreter.Relationship.Context("Tom");
            Console.WriteLine(isSingle.Interpret(context));
            context.SetInput("Andrew");
            Console.WriteLine(isSingle.Interpret(context));

            context.SetInput("Committed, Alice");
            Console.WriteLine(isCommitted.Interpret(context));
            context.SetInput("Single, Alice");
            Console.WriteLine(isCommitted.Interpret(context));

            Console.WriteLine("---------------------------------------------------\n");
        }