/// <summary>
 /// Initializes a new instance of the <see cref="LfMerge.DataConverters.ConvertFdoToMongoOptionList"/> class.
 /// </summary>
 /// <param name="lfOptionList">Lf option list.</param>
 /// <param name="wsForKeys">Ws for keys.</param>
 /// <param name="listCode">List code.</param>
 /// <param name="logger">Logger.</param>
 public ConvertFdoToMongoOptionList(LfOptionList lfOptionList, int wsForKeys, string listCode, ILogger logger, ILgWritingSystemFactory wsf)
 {
     _logger = logger;
     _wsf = wsf;
     _wsForKeys = wsForKeys;
     if (lfOptionList == null)
         lfOptionList = MakeEmptyOptionList(listCode);
     _lfOptionList = lfOptionList;
     UpdateOptionListItemDictionaries(_lfOptionList);
 }
 private LfOptionList CreateLfGrammarWith(IEnumerable<LfOptionListItem> grammarItems)
 {
     var result = new LfOptionList();
     result.Code = MagicStrings.LfOptionListCodeForGrammaticalInfo;
     result.Name = MagicStrings.FdoOptionlistNames[MagicStrings.LfOptionListCodeForGrammaticalInfo];
     result.DateCreated = result.DateModified = System.DateTime.Now;
     result.CanDelete = false;
     result.DefaultItemKey = null;
     result.Items = grammarItems.ToList();
     return result;
 }
 protected LfOptionList MakeEmptyOptionList(string listCode)
 {
     var result = new LfOptionList();
     result.Items = new List<LfOptionListItem>();
     result.DateCreated = result.DateModified = DateTime.Now;
     result.Code = listCode;
     result.Name = FdoOptionListName(listCode);
     result.CanDelete = false;
     result.DefaultItemKey = null;
     return result;
 }
 protected void UpdateOptionListItemDictionaries(LfOptionList lfOptionList)
 {
     _lfOptionListItemByGuid = lfOptionList.Items
         .Where(item => item.Guid != null)
         .ToDictionary(item => item.Guid.Value, item => item);
     _lfOptionListItemByStrKey = lfOptionList.Items
         .ToDictionary(item => item.Key, item => item);
     _lfOptionListItemKeyByGuid = _lfOptionList.Items
         .Where(item => item.Guid != null)
         .ToDictionary(
             item => item.Guid.GetValueOrDefault(),
             item => item.Key
         );
 }
 // Clone old option list into new list, changing only the items
 // ... We could use a MongoDB update query for this, but that would
 // require new code in MongoConnection and MongoConnectionDouble.
 // TODO: We pretty much have that code by now. See if we can get rid of this function by now.
 protected LfOptionList CloneOptionListWithEmptyItems(LfOptionList original)
 {
     var newList = new LfOptionList();
     newList.CanDelete = original.CanDelete;
     newList.Code = original.Code;
     newList.DateCreated = original.DateCreated;
     newList.DateModified = DateTime.Now;
     newList.DefaultItemKey = original.DefaultItemKey;
     newList.Name = original.Name;
     // lfNewOptionList.Items is set to an empty list by its constructor; no need to set it here.
     return newList;
 }