当前位置: 首页>>代码示例>>C#>>正文


C# StringScanner.Scan方法代码示例

本文整理汇总了C#中StringScanner.Scan方法的典型用法代码示例。如果您正苦于以下问题:C# StringScanner.Scan方法的具体用法?C# StringScanner.Scan怎么用?C# StringScanner.Scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringScanner的用法示例。


在下文中一共展示了StringScanner.Scan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input)
        {
            if (engine == null) throw ShellExpcetion.NoDatabase();

            var direction = s.Scan(@"[><]\s*").Trim();
            var filename = s.Scan(@".+").Trim();

            //dump import
            if(direction == "<")
            {
                using (var reader = new StreamReader(filename, Encoding.UTF8))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        engine.Run(line, new Display()); // no output
                    }
                }
            }
            // dump export
            else
            {
                using (var writer = new StreamWriter(filename, false, Encoding.UTF8, 65536))
                {
                    writer.AutoFlush = true;
                    writer.WriteLine("-- LiteDB v{0}.{1}.{2} dump file @ {3}", 
                        engine.Version.Major, engine.Version.Minor, engine.Version.Build,
                        DateTime.Now);
                    engine.Dump(writer);
                    writer.Flush();
                }
            }
        }
开发者ID:AshishVishwakarma,项目名称:LiteDB,代码行数:33,代码来源:Dump.cs

示例2: GetCode

        public static Action<object, BsonDocument, LiteCollection<BsonDocument>, LiteDatabase> GetCode(StringScanner s)
        {
            var str = s.Scan(@"[\s\S]*");
            var code = CODE_TEMPLATE.Replace("[code]", str);
            var provider = new CSharpCodeProvider();
            var parameters = new CompilerParameters();

            parameters.ReferencedAssemblies.Add("LiteDB.dll");
            parameters.GenerateInMemory = true;
            parameters.GenerateExecutable = false;

            var results = provider.CompileAssemblyFromSource(parameters, code);

            if (results.Errors.HasErrors)
            {
                var err = new StringBuilder();
                foreach (CompilerError error in results.Errors)
                {
                    err.AppendLine(String.Format("Error ({0}): {1}", error.ErrorNumber, error.ErrorText));
                }
                throw new InvalidOperationException(err.ToString().Trim());
            }

            var assembly = results.CompiledAssembly;
            var program = assembly.GetType("Program");
            var method = program.GetMethod("DoWork");

            return new Action<object, BsonDocument, LiteCollection<BsonDocument>, LiteDatabase>((id, doc, col, db) =>
            {
                method.Invoke(null, new object[] { id, doc, col, db });
            });
        }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:32,代码来源:Exec.cs

示例3: Execute

        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var index = s.Scan(this.FieldPattern).Trim();

            display.WriteResult(engine.Max(col, index.Length == 0 ? "_id" : index));
        }
开发者ID:apkd,项目名称:LiteDB,代码行数:7,代码来源:Max.cs

示例4: Execute

        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var col = this.ReadCollection(engine, s);
            var newName = s.Scan(@"[\w-]+").ThrowIfEmpty("Invalid new collection name");

            return engine.RenameCollection(col, newName);
        }
开发者ID:ChrisCross67,项目名称:LiteDB,代码行数:7,代码来源:Rename.cs

示例5: Execute

        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var col = this.ReadCollection(engine, s);
            var index = s.Scan(this.FieldPattern).Trim();

            return engine.Min(col, index.Length == 0 ? "_id" : index);
        }
开发者ID:AshishVishwakarma,项目名称:LiteDB,代码行数:7,代码来源:Min.cs

示例6: Execute

        public override void Execute(LiteShell shell, StringScanner s, Display display, InputCommand input)
        {
            if(s.Scan("false|off").Length > 0 && _writer != null)
            {
                display.TextWriters.Remove(_writer);
                input.OnWrite = null;
                _writer.Flush();
                _writer.Dispose();
                _writer = null;
            }
            else if(_writer == null)
            {
                if (shell.Database == null) throw LiteException.NoDatabase();

                var dbfilename = shell.Database.ConnectionString.Filename;
                var path = Path.Combine(Path.GetDirectoryName(dbfilename),
                    string.Format("{0}-spool-{1:yyyy-MM-dd-HH-mm}.txt", Path.GetFileNameWithoutExtension(dbfilename), DateTime.Now));

                _writer = File.CreateText(path);

                display.TextWriters.Add(_writer);

                input.OnWrite = (t) => _writer.Write(t);
            }
        }
开发者ID:azraelrabbit,项目名称:LiteDB,代码行数:25,代码来源:Spool.cs

示例7: Execute

        public BsonValue Execute(LiteDatabase db, StringScanner s)
        {
            var col = this.ReadCollection(db, s);
            var index = s.Scan(this.FieldPattern).Trim();

            return col.Max(index.Length == 0 ? "_id" : index);
        }
开发者ID:azraelrabbit,项目名称:LiteDB,代码行数:7,代码来源:Max.cs

示例8: Execute

        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var newName = s.Scan(@"[\w-]+").ThrowIfEmpty("Invalid new collection name");

            display.WriteResult(engine.RenameCollection(col, newName));
        }
开发者ID:apkd,项目名称:LiteDB,代码行数:7,代码来源:Rename.cs

示例9: Execute

        public BsonValue Execute(LiteDatabase db, StringScanner s)
        {
            var col = this.ReadCollection(db, s);
            var newName = s.Scan(@"[\w-]+");

            return db.RenameCollection(col.Name, newName);
        }
开发者ID:azraelrabbit,项目名称:LiteDB,代码行数:7,代码来源:Rename.cs

示例10: Execute

        public void Execute(LiteEngine engine, StringScanner s, Display d, InputCommand input, Env env)
        {
            var sb = new StringBuilder();
            var enabled = !(s.Scan(@"off\s*").Length > 0);

            env.Log.Level = enabled ? Logger.FULL : Logger.NONE;
        }
开发者ID:apkd,项目名称:LiteDB,代码行数:7,代码来源:Debug.cs

示例11: Execute

        public override void Execute(ref LiteDatabase db, StringScanner s, Display d, InputCommand input)
        {
            var sb = new StringBuilder();
            var enabled = !(s.Scan(@"off\s*").Length > 0);

            db.Log.Level = enabled ? Logger.FULL : Logger.NONE;
        }
开发者ID:ktaranov,项目名称:LiteDB,代码行数:7,代码来源:Debug.cs

示例12: Execute

        public override void Execute(ref IShellEngine engine, StringScanner s, Display d, InputCommand input)
        {
            var sb = new StringBuilder();
            var enabled = !(s.Scan(@"off\s*").Length > 0);

            if(engine == null) throw ShellExpcetion.NoDatabase();

            engine.Debug(enabled);
        }
开发者ID:AshishVishwakarma,项目名称:LiteDB,代码行数:9,代码来源:Debug.cs

示例13: Execute

        public override void Execute(LiteShell shell, StringScanner s, Display display, InputCommand input)
        {
            var filename = s.Scan(@".+").Trim();

            foreach (var line in File.ReadAllLines(filename))
            {
                input.Queue.Enqueue(line);
            }
        }
开发者ID:azraelrabbit,项目名称:LiteDB,代码行数:9,代码来源:Run.cs

示例14: Execute

        public override void Execute(LiteShell shell, StringScanner s, Display display, InputCommand input)
        {
            var filename = s.Scan(@".+");

            if (shell.Database != null)
            {
                shell.Database.Dispose();
            }

            shell.Database = new LiteDatabase(filename);
        }
开发者ID:azraelrabbit,项目名称:LiteDB,代码行数:11,代码来源:Open.cs

示例15: Execute

        public override void Execute(ref LiteDatabase db, StringScanner s, Display display, InputCommand input)
        {
            var filename = s.Scan(@".+");

            if (db != null)
            {
                db.Dispose();
            }

            db = new LiteDatabase(filename);
        }
开发者ID:ktaranov,项目名称:LiteDB,代码行数:11,代码来源:Open.cs


注:本文中的StringScanner.Scan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。