当前位置: 首页>>代码示例>>C#>>正文


C# BsonValue.ToJson方法代码示例

本文整理汇总了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);
开发者ID:ermshiperete,项目名称:LfMerge,代码行数:67,代码来源:ConvertMongoToFdoCustomField.cs


注:本文中的BsonValue.ToJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。