예제 #1
0
파일: Spool.cs 프로젝트: vnvizitiu/LiteDB
        public void Execute(StringScanner s, Env env)
        {
            if (s.Scan("false|off").Length > 0 && _writer != null)
            {
                env.Display.TextWriters.Remove(_writer);
                env.Input.OnWrite = null;
                _writer.Flush();
                _writer.Dispose();
                _writer = null;
            }
            else if (_writer == null)
            {
                if (env.Engine == null)
                {
                    throw ShellException.NoDatabase();
                }

                var path = Path.GetFullPath(string.Format("LiteDB-spool-{0:yyyy-MM-dd-HH-mm}.txt", DateTime.Now));

                _writer = File.CreateText(path);

                env.Display.TextWriters.Add(_writer);

                env.Input.OnWrite = (t) => _writer.Write(t);
            }
        }
예제 #2
0
파일: Run.cs 프로젝트: andyp22/c-sharp-libs
        public void Execute(StringScanner s, Env env)
        {
            if (env.Engine == null)
            {
                throw ShellException.NoDatabase();
            }

            var filename = s.Scan(@".+").Trim();

            foreach (var line in File.ReadAllLines(filename))
            {
                env.Input.Queue.Enqueue(line);
            }
        }
예제 #3
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            if (engine == null)
            {
                throw ShellException.NoDatabase();
            }

            var filename = s.Scan(@".+").Trim();

            foreach (var line in File.ReadAllLines(filename))
            {
                input.Queue.Enqueue(line);
            }
        }