本文整理汇总了C#中Doc.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Doc.Add方法的具体用法?C# Doc.Add怎么用?C# Doc.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doc
的用法示例。
在下文中一共展示了Doc.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadDoc
public Doc ReadDoc()
{
var doc = new Doc();
ReadInt32(); //size (ignored)
while(true)
{
var type = (BsonType)ReadByte();
if (type == BsonType.EOO)
{
return doc;
}
var name = ReadShortString();
object o = null;
switch (type)
{
case BsonType.NUMBER:
o = ReadDouble();
break;
case BsonType.STRING:
o = ReadString(ReadInt32());
break;
case BsonType.OBJECT:
o = ReadDoc();
break;
case BsonType.ARRAY:
o = ReadDoc().ToList();
break;
case BsonType.BINARY:
var count = ReadInt32();
ReadByte(); //TODO: handle 'subtype'
o = ReadBytes(count);
break;
case BsonType.UNDEFINED:
break;
case BsonType.OID:
o = ReadObjectId();
break;
case BsonType.BOOLEAN:
o = ReadBoolean();
break;
case BsonType.DATE:
o = ReadDate();
break;
case BsonType.NULL:
break;
case BsonType.REGEX:
o = new Regex(ReadShortString());
ReadShortString(); //TODO: options
break;
case BsonType.REF:
o = ReadDBRef();
break;
case BsonType.CODE:
o = new Code(ReadString(ReadInt32()));
break;
case BsonType.SYMBOL:
o = new Symbol(ReadString(ReadInt32()));
break;
case BsonType.CODE_W_SCOPE:
ReadInt32();
o = new ScopedCode(ReadString(ReadInt32()), ReadDoc());
break;
case BsonType.NUMBER_INT:
o = ReadInt32();
break;
case BsonType.TIMESTAMP:
o = new TimeStamp(ReadInt64());
break;
case BsonType.NUMBER_LONG:
o = ReadInt64();
break;
case BsonType.MINKEY:
break;
case BsonType.MAXKEY:
break;
default:
break;
}
doc.Add(name, o);
}
}