本文整理汇总了C#中ODocument.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ODocument.Add方法的具体用法?C# ODocument.Add怎么用?C# ODocument.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ODocument
的用法示例。
在下文中一共展示了ODocument.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseFieldName
private static int ParseFieldName(int i, string recordString, ODocument document)
{
int startIndex = i;
// iterate until colon is found since it's the character which ends the field name
while (recordString[i] != ':')
{
i++;
if (i >= recordString.Length)
{
return recordString.Length;
}
}
// parse field name string from raw document string
string fieldName = recordString.Substring(startIndex, i - startIndex);
int pos = fieldName.IndexOf('@');
if (pos > 0)
{
fieldName = fieldName.Substring(pos + 1, fieldName.Length - pos - 1);
}
fieldName = fieldName.Replace("\"", "");
document.Add(fieldName, null);
// move to position after colon (:)
i++;
// check if it's not the end of document which means that current field has null value
if (i == recordString.Length)
{
return i;
}
// check what follows after parsed field name and start parsing underlying type
switch (recordString[i])
{
case '"':
i = ParseString(i, recordString, document, fieldName);
break;
case '#':
i = ParseRecordID(i, recordString, document, fieldName);
break;
case '(':
i = ParseEmbeddedDocument(i, recordString, document, fieldName);
break;
case '[':
i = ParseList(i, recordString, document, fieldName);
break;
case '<':
i = ParseSet(i, recordString, document, fieldName);
break;
case '{':
i = ParseMap(i, recordString, document, fieldName);
break;
case '%':
i = ParseRidBags(i, recordString, document, fieldName);
break;
default:
i = ParseValue(i, recordString, document, fieldName);
break;
}
// check if it's not the end of document which means that current field has null value
if (i == recordString.Length)
{
return i;
}
// single string value was parsed and we need to push the index if next character is comma
if (recordString[i] == ',')
{
i++;
}
return i;
}