本文整理汇总了C#中Display.WriteResult方法的典型用法代码示例。如果您正苦于以下问题:C# Display.WriteResult方法的具体用法?C# Display.WriteResult怎么用?C# Display.WriteResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Display
的用法示例。
在下文中一共展示了Display.WriteResult方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: 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));
}
示例3: 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));
}
示例4: Execute
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
var col = this.ReadCollection(engine, s);
var value = JsonSerializer.Deserialize(s.ToString());
if (value.IsArray)
{
display.WriteResult(engine.Insert(col, value.AsArray.RawValue.Select(x => x.AsDocument)));
}
else
{
engine.Insert(col, new BsonDocument[] { value.AsDocument });
display.WriteResult(value.AsDocument["_id"]);
}
}
示例5: Execute
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
var fs = new LiteStorage(engine);
var id = this.ReadId(s);
display.WriteResult(fs.Delete(id));
}
示例6: Execute
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
var fs = new LiteStorage(engine);
if (s.HasTerminated)
{
var files = fs.FindAll().Select(x => x.AsDocument);
display.WriteResult(new BsonArray(files));
}
else
{
var id = this.ReadId(s);
var files = fs.Find(id).Select(x => x.AsDocument);
display.WriteResult(new BsonArray(files));
}
}
示例7: Execute
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
var col = this.ReadCollection(engine, s);
display.WriteResult(new BsonArray(engine.GetIndexes(col).Select(x => new BsonDocument
{
{ "slot", x.Slot },
{ "field", x.Field },
{ "unique", x.Unique }
})));
}
示例8: Execute
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
var col = this.ReadCollection(engine, s);
var filename = s.Scan(@".*");
using (var sr = new StreamReader(filename, Encoding.UTF8))
{
var docs = JsonSerializer.DeserializeArray(sr);
display.WriteResult(engine.Insert(col, docs.Select(x => x.AsDocument)));
}
}
示例9: Execute
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
var fs = new LiteStorage(engine);
var id = this.ReadId(s);
var filename = s.Scan(@"\s*.*").Trim();
if (!File.Exists(filename)) throw new IOException("File " + filename + " not found");
var file = fs.Upload(id, filename);
display.WriteResult(file.AsDocument);
}
示例10: Execute
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
var fs = new LiteStorage(engine);
var id = this.ReadId(s);
var filename = s.Scan(@"\s*.*").Trim();
var file = fs.FindById(id);
if (file != null)
{
file.SaveAs(filename);
display.WriteResult(file.AsDocument);
}
}
示例11: Execute
public void Execute(LiteEngine db, StringScanner s, Display d)
{
d.WriteResult("Web Shell Commands - try offline version for more commands");
d.WriteResult("==========================================================");
d.WriteHelp("> db.<collection>.insert <jsonDoc>", "Insert a new document into collection");
d.WriteHelp("> db.<collection>.update <jsonDoc>", "Update a document inside collection");
d.WriteHelp("> db.<collection>.delete <filter>", "Delete documents using a filter clausule (see find)");
d.WriteHelp("> db.<collection>.find [top N] <filter>", "Show filtered documents based on index search");
d.WriteHelp("> db.<collection>.count <filter>", "Show count rows according query filter");
d.WriteHelp("> db.<collection>.ensureIndex <field> [unique]", "Create a new index document field");
d.WriteHelp("> db.<collection>.indexes", "List all indexes in this collection");
d.WriteHelp("<filter> = <field> [=|>|>=|<|<=|!=|like|between] <jsonValue>", "Filter query syntax");
d.WriteHelp("<filter> = (<filter> [and|or] <filter> [and|or] ...)", "Multi queries syntax");
d.WriteResult("Try:");
d.WriteResult(" > db.customers.insert { _id:1, name:\"John Doe\", age: 37 }");
d.WriteResult(" > db.customers.ensureIndex name");
d.WriteResult(" > db.customers.find name like \"John\"");
d.WriteResult(" > db.customers.find top 10 (name like \"John\" and _id between [0, 100])");
}
示例12: Execute
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
var col = this.ReadCollection(engine, s);
var field = s.Scan(this.FieldPattern).Trim().ThrowIfEmpty("Invalid field name");
var unique = false;
s.Scan(@"\s*");
if (s.HasTerminated == false)
{
var options = JsonSerializer.Deserialize(s.ToString());
if (options.IsBoolean)
{
unique = options.AsBoolean;
}
else if (options.IsDocument) // support old version index definitions
{
unique = options.AsDocument["unique"].AsBoolean;
}
}
display.WriteResult(engine.EnsureIndex(col, field, unique));
}
示例13: Execute
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
var col = this.ReadCollection(engine, s);
display.WriteResult(engine.DropCollection(col));
}