コード例 #1
0
            public InterpretedClass(ClassDeclarationExpression expression, Scope scope)
            {
                _rootscope        = scope.Root;
                _name             = expression.Name;
                _parents          = expression.Parents;
                _interfaces       = expression.Interfaces;
                _methods          = new MethodCollection();
                _fields           = new FieldCollection();
                _classes          = new ClassCollection();
                _static_variables = new VariableCollection();

                ScriptScope script_scope = null;

                scope.FindNearestScope <ScriptScope> (ss => script_scope = ss);

                foreach (ClassMethodDeclarationExpression m in expression.Methods)
                {
                    _methods.Add(new InterpretedMethod(m, script_scope));
                }

                foreach (ClassFieldDeclarationExpression f in expression.Fields)
                {
                    IVariable var = _static_variables.EnsureExists(f.Name);
                    if (f.Initializer is Expression initializer_expr)
                    {
                        var.Value = Interpreters.Execute(initializer_expr, script_scope).ResultValue;
                    }
                }
            }
コード例 #2
0
        public IPipelineBuilder <TRequest> Call <THandler>(Action <THandler, TRequest> action)
        {
            Action <object, object> typedHandler = (h, r) => action((THandler)h, (TRequest)r);
            var method = new Method <Action <object, object> >(typeof(THandler), typedHandler);

            _methods.Add(method);
            return(this);
        }
コード例 #3
0
        public ICancellablePipelineAsyncBuilder <TRequest> Call <THandler>(Func <THandler, TRequest, CancellationToken, Task> func)
        {
            Func <object, object, CancellationToken, Task> typedHandler = async(h, r, c) => await func((THandler)h, (TRequest)r, c);

            var method = new Method <Func <object, object, CancellationToken, Task> >(typeof(THandler), typedHandler);

            _methods.Add(method);
            return(this);
        }
コード例 #4
0
        public IAsyncPipelineBuilder <TRequest> Call <THandler>(Func <THandler, TRequest, Task> func)
        {
            Func <object, object, Task> typedHandler = async(h, r) => await func((THandler)h, (TRequest)r);

            var method = new Method <Func <object, object, Task> >(typeof(THandler), typedHandler);

            _methods.Add(method);
            return(this);
        }