Exemplo n.º 1
0
        public ShellContext(IServiceProvider serviceProvider, ShellContext parent = null)
        {
            ServiceProvider = serviceProvider;
            _logger         = this.GetLogger <ShellContext>();
            if (parent == null)
            {
                _scope = new VariableScope(null);

                _dbCache = new Dictionary <string, DatabaseInfo>();
            }
            else
            {
                _parent  = parent;
                _dbCache = _parent._dbCache;
            }
        }
Exemplo n.º 2
0
        public ShellContext(ShellContext parent = null)
        {
            if (parent == null)
            {
                //_engine = Python.CreateEngine();
                _engine = GetEngine();
                _scope = _engine.CreateScope();

                _dbCache = new Dictionary<string, DatabaseInfo>();
            }
            else
            {
                _parent = parent;

                _engine = _parent._engine;
                _dbCache = _parent._dbCache;

                OnOutputMessage += ShellContext_OnOutputMessage;
            }
        }
Exemplo n.º 3
0
 public static void ParseRazor(string templateData, Action<string> write, object model, Action<IRazorTemplate, IShellContext> initTemplate = null, IShellContext context = null)
 {
     if (!_initialized)
     {
         Initialize();
     }
     if (context == null)
     {
         context = new ShellContext(null);
         if (InitializeContext != null) InitializeContext(context);
     }
     Action<ITemplate> func = tpl =>
         {
             var rtpl = (IRazorTemplate) tpl;
             rtpl.Reset();
             rtpl.Context = context;
             if (initTemplate != null) initTemplate(rtpl, context);
             if (InitializeTemplate != null) InitializeTemplate(rtpl);
         };
     RazorEngine.Razor.Parse(templateData, write, model, null, func);
 }
Exemplo n.º 4
0
 public ShellRunner()
 {
     _context = new ShellContext();
     _context.OnOutputMessage += _context_OnOutputMessage;
 }
Exemplo n.º 5
0
 public ShellRunner(IServiceProvider serviceProvider)
 {
     ServiceProvider = serviceProvider;
     _context        = new ShellContext(serviceProvider);
 }