public void FuncVisitor_Visit_Success()
        {
            var mock = new Mock <VisitorTests>();

            IFuncVisitor <Letter, int> visitor = Visitor.For <Letter, int>();

            visitor.Register <A>(mock.Object.VisitFunc);
            var value = new A();

            visitor.Visit(value);
            mock.Verify(x => x.VisitFunc(value));
        }
Example #2
0
 public PerformanceTestState(IInterpreterRepository repository, ISpatialRepository spatialRepository, IQueryReader queryReader, ISymbolVisitor symbolVisitor,
                             IExecutionVisitor executionVisitor, IFuncVisitor funcVisitor, ILogger logger, ISettings settings, string name)
 {
     Repository            = repository;
     SpatialRepository     = spatialRepository;
     this.queryReader      = queryReader;
     this.symbolVisitor    = symbolVisitor;
     this.executionVisitor = executionVisitor;
     this.funcVisitor      = funcVisitor;
     this.logger           = logger;
     this.settings         = settings;
     this.Name             = name;
 }
Example #3
0
        private static void FuncVisitor()
        {
            Console.WriteLine("Func Visitor");
            IFuncVisitor <Letter, string> visitor = Visitor.For <Letter, string>();

            visitor.Register <A>(x => x.GetType().Name);
            visitor.Register <B>(x => x.GetType().Name);

            Letter a = new A();
            Letter b = new B();

            Console.WriteLine(visitor.Visit(a));
            Console.WriteLine(visitor.Visit(b));
        }
Example #4
0
            public void Do()
            {
                Console.WriteLine("Func Visitor");
                IFuncVisitor <Letter, string> visitor = Visitor.For <Letter, string>();

                visitor.Register <A>(ProcessA);
                visitor.Register <B>(ProcessB);

                Letter a = new A();
                Letter b = new B();

                Console.WriteLine(visitor.Visit(a));
                Console.WriteLine(visitor.Visit(b));
            }
Example #5
0
        public ExecuteAllState(SymbolClearState clearState, IInterpreterRepository repository, ISpatialRepository spatialRepository, IQueryReader queryReader,
                               ISymbolVisitor symbolVisitor, IExecutionVisitor executionVisitor, IFuncVisitor funcVisitor,
                               string name, QueryShowState queryShowState, ResultShowState resultShowState)
        {
            Repository            = repository;
            SpatialRepository     = spatialRepository;
            this.clearState       = clearState;
            this.queryReader      = queryReader;
            this.symbolVisitor    = symbolVisitor;
            this.executionVisitor = executionVisitor;
            this.funcVisitor      = funcVisitor;
            this.queryShowState   = queryShowState;
            this.resultShowState  = resultShowState;

            Name = name;
        }
Example #6
0
        public Context(IQueryReader queryReader, ISymbolVisitor symbolVisitor, IExecutionVisitor executionVisitor, IFuncVisitor funcVisitor,
                       ISpatialRepository spatialRepository, IInterpreterRepository repository, ISettings settings, ILogger logger)
        {
            this.spatialRepository = spatialRepository;

            queryClearState = new QueryClearState()
            {
                Repository = repository, Name = "QueryClearState"
            };
            queryAddState = new QueryAddState()
            {
                Repository = repository, Name = "QueryAddState"
            };
            queryShowState = new QueryShowState(queryAddState)
            {
                Repository = repository, Name = "QueryShowState"
            };
            queryAddState.ShowState = queryShowState;

            symbolShowState  = new SymbolShowState(repository, "SymbolShowState");
            symbolClearState = new SymbolClearState(repository, spatialRepository, symbolShowState, queryShowState, "SymbolClearState");

            resultShowState = new ResultShowState(repository, queryShowState, "ResultShowState");
            executeAllState = new ExecuteAllState(symbolClearState, repository, spatialRepository, queryReader, symbolVisitor, executionVisitor, funcVisitor,
                                                  "ExecuteAllState", queryShowState, resultShowState);

            resultWriteState = new ResultWriteState(repository, "ResultWriteState", resultShowState);

            showSettingsState = new ShowSettingsState(settings, "ShowSettingsState");
            showLicenceState  = new ShowLicenceState(queryAddState, "ShowLicenceState");

            performanceTestState = new PerformanceTestState(repository, spatialRepository, queryReader, symbolVisitor, executionVisitor,
                                                            funcVisitor, logger, settings, "PerformanceTestState");

            currentState = showLicenceState;
            currentState = currentState.Execute("");
        }
Example #7
0
 public void Accept(IFuncVisitor funcVisitor)
 {
     funcVisitor.Visit(this);
 }