Example #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;
            }
        }
Example #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;
            }
        }
Example #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);
 }
Example #4
0
 public ShellRunner()
 {
     _context = new ShellContext();
     _context.OnOutputMessage += _context_OnOutputMessage;
 }
Example #5
0
 public ShellRunner(IServiceProvider serviceProvider)
 {
     ServiceProvider = serviceProvider;
     _context        = new ShellContext(serviceProvider);
 }