本文整理汇总了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;
}
}
示例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));
}
示例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));
}
示例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);
}
示例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 });
}
示例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);
}
示例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 });
});
}
示例8: Execute
public BsonValue Execute(LiteDatabase db, StringScanner s)
{
var col = this.ReadCollection(db, s);
var query = this.ReadQuery(s);
return col.Delete(query);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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));
}
示例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;
}