コード例 #1
0
ファイル: ShellContext.cs プロジェクト: timothydodd/dbshell
        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;
            }
        }
コード例 #2
0
ファイル: ShellContext.cs プロジェクト: dbshell/dbshell
        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;
            }
        }
コード例 #3
0
ファイル: RazorScripting.cs プロジェクト: dbshell/dbshell
 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);
 }
コード例 #4
0
ファイル: ShellRunner.cs プロジェクト: dbshell/dbshell
 public ShellRunner()
 {
     _context = new ShellContext();
     _context.OnOutputMessage += _context_OnOutputMessage;
 }
コード例 #5
0
ファイル: ShellRunner.cs プロジェクト: timothydodd/dbshell
 public ShellRunner(IServiceProvider serviceProvider)
 {
     ServiceProvider = serviceProvider;
     _context        = new ShellContext(serviceProvider);
 }