本文整理汇总了C#中StringScanner.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# StringScanner.ToString方法的具体用法?C# StringScanner.ToString怎么用?C# StringScanner.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringScanner
的用法示例。
在下文中一共展示了StringScanner.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: 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"]);
}
}
示例3: ReadOneQuery
private Query ReadOneQuery(StringScanner s)
{
var field = s.Scan(this.FieldPattern).Trim().ThrowIfEmpty("Invalid field name");
var oper = s.Scan(@"(=|!=|>=|<=|>|<|like|in|between|contains)").ThrowIfEmpty("Invalid query operator");
var value = JsonSerializer.Deserialize(s.ToString());
switch (oper)
{
case "=": return Query.EQ(field, value);
case "!=": return Query.Not(field, value);
case ">": return Query.GT(field, value);
case ">=": return Query.GTE(field, value);
case "<": return Query.LT(field, value);
case "<=": return Query.LTE(field, value);
case "like": return Query.StartsWith(field, value);
case "in": return Query.In(field, value.AsArray);
case "between": return Query.Between(field, value.AsArray[0], value.AsArray[1]);
case "contains": return Query.Contains(field, value);
default: throw new LiteException("Invalid query operator");
}
}
示例4: 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));
}
示例5: Deserialize
/// <summary>
/// Deserialize a json using a StringScanner and returns BsonValue
/// </summary>
public static BsonValue Deserialize(StringScanner s)
{
if (s == null) throw new ArgumentNullException("s");
if (s.HasTerminated) return BsonValue.Null;
using (var sr = new StringReader(s.ToString()))
{
var reader = new JsonReader(sr);
var value = reader.Deserialize();
s.Seek((int)(reader.Position - 1));
return value;
}
}