本文整理汇总了C#中BsonValue.ToJson方法的典型用法代码示例。如果您正苦于以下问题:C# BsonValue.ToJson方法的具体用法?C# BsonValue.ToJson怎么用?C# BsonValue.ToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonValue
的用法示例。
在下文中一共展示了BsonValue.ToJson方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetCustomFieldData
//.........这里部分代码省略.........
}
}
// Shortcut: if text contents haven't changed, we don't want to change anything at all
BsonValue currentFdoTextContents = ConvertUtilities.GetCustomStTextValues(text, flid,
cache.ServiceLocator.WritingSystemManager, cache.MetaDataCacheAccessor, cache.DefaultUserWs);
if ((currentFdoTextContents == BsonNull.Value || currentFdoTextContents == null) &&
(value == BsonNull.Value || value == null))
return false;
if (currentFdoTextContents != null && currentFdoTextContents.Equals(value))
{
// No changes needed.
return false;
}
// BsonDocument passed in contains "paragraphs". ParseCustomStTextValuesFromBson wants only a "value" element
// inside the doc, so we'll need to construct a new doc for the StTextValues.
BsonDocument doc = value.AsBsonDocument;
LfMultiParagraph multiPara = BsonSerializer.Deserialize<LfMultiParagraph>(doc);
// Now we have another way to check for "old value and new value were the same": if the FDO multiparagraph was empty,
// GetCustomStTextValues will have returned null -- so if this multiPara has no paragraphs, that's also an unchanged situation
if ((multiPara.Paragraphs == null || multiPara.Paragraphs.Count <= 0) &&
(currentFdoTextContents == BsonNull.Value || currentFdoTextContents == null))
return false;
int wsId;
if (multiPara.InputSystem == null)
wsId = cache.MetaDataCacheAccessor.GetFieldWs(flid);
else
wsId = cache.WritingSystemFactory.GetWsFromStr(multiPara.InputSystem);
ConvertUtilities.SetCustomStTextValues(text, multiPara.Paragraphs, wsId);
return true;
}
case CellarPropertyType.ReferenceAtomic:
Console.WriteLine("ReferenceAtomic field named {0} with value {1}", fieldName, value.ToJson());
int log_fieldWs = fdoMetaData.GetFieldWs(flid);
string log_fieldWsStr = servLoc.WritingSystemManager.GetStrFromWs(log_fieldWs);
Console.WriteLine("Writing system for this field has ID {0} and name ({1})", log_fieldWs, log_fieldWsStr);
if (fieldGuids.First() != Guid.Empty)
{
int referencedHvo = data.get_ObjFromGuid(fieldGuids.First());
int oldHvo = data.get_ObjectProp(hvo, flid);
if (referencedHvo == oldHvo)
return false;
else
{
data.SetObjProp(hvo, flid, referencedHvo);
// TODO: What if the value of the referenced object has changed in LanguageForge? (E.g., change that possibility's text from "foo" to "bar")
// Need to implement that scenario.
return true;
}
}
else
{
// It's a reference to an ICmPossibility instance: create a new entry in appropriate PossibilityList
LfStringField valueAsLfStringField = BsonSerializer.Deserialize<LfStringField>(value.AsBsonDocument);
string nameHierarchy = valueAsLfStringField.Value;
if (nameHierarchy == null)
return false;
int fieldWs = fdoMetaData.GetFieldWs(flid);
// Oddly, this can return 0 for some custom fields. TODO: Find out why: that seems like it would be an error.
if (fieldWs == 0)
fieldWs = cache.DefaultUserWs;
ICmPossibilityList parentList = GetParentListForField(flid);
ICmPossibility newPoss = parentList.FindOrCreatePossibility(nameHierarchy, fieldWs);
int oldHvo = data.get_ObjectProp(hvo, flid);