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


C# StringScanner类代码示例

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


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

示例1: Execute

        public BsonValue Execute(LiteDatabase db, StringScanner s)
        {
            var col = this.ReadCollection(db, s);
            var query = s.Match("{") ? Query.Query.All() : this.ReadQuery(s);
            var code = DynamicCode.GetCode(s);

            var docs = col.Find(query).ToArray();

            try
            {
                db.BeginTrans();

                foreach (var doc in docs)
                {
                    code(doc["_id"], doc, col, db);
                }

                db.Commit();

                return docs.Length;
            }
            catch (Exception ex)
            {
                db.Rollback();
                throw ex;
            }
        }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:27,代码来源:Exec.cs

示例2: 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

示例3: Execute

        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var doc = JsonSerializer.Deserialize(s.ToString()).AsDocument;

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

示例4: 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

示例5: Execute

        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var col = this.ReadCollection(engine, s);
            var doc = JsonSerializer.Deserialize(s).AsDocument;

            return engine.Update(col, new BsonDocument[] { doc });
        }
开发者ID:ktaranov,项目名称:LiteDB,代码行数:7,代码来源:Update.cs

示例6: Execute

        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var col = this.ReadCollection(engine, s);
            var query = this.ReadQuery(s);

            return engine.Delete(col, query);
        }
开发者ID:AshishVishwakarma,项目名称:LiteDB,代码行数:7,代码来源:Delete.cs

示例7: 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

示例8: Execute

        public BsonValue Execute(LiteDatabase db, StringScanner s)
        {
            var col = this.ReadCollection(db, s);
            var query = this.ReadQuery(s);

            return col.Delete(query);
        }
开发者ID:azraelrabbit,项目名称:LiteDB,代码行数:7,代码来源:Delete.cs

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: Execute

        public BsonValue Execute(LiteDatabase db, StringScanner s)
        {
            var col = this.ReadCollection(db, s);
            var doc = JsonSerializer.Deserialize(s).AsDocument;

            return col.Update(doc);
        }
开发者ID:azraelrabbit,项目名称:LiteDB,代码行数:7,代码来源:Update.cs

示例14: 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

示例15: 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


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