override public void Save()
        {
            //delete anything we're going to delete first, to prevent losing
            //a WS we want by having it deleted by an old WS we don't want
            //(but which has the same identifier)
            var idsToRemove = new List <string>();

            foreach (var ws in AllWritingSystems)
            {
                if (ws.MarkedForDeletion)
                {
                    idsToRemove.Add(ws.StoreID);                    //nb: purposefully not removing from our list, for fear of leading to bugs in the UI. If we did this, we'd want to require the UI to reload the WS list after a save.
                }
            }
            foreach (string id in idsToRemove)
            {
                Remove(id);
            }

            // make a copy and then go through that list - SaveDefinition calls Set which
            // may delete and then insert the same writing system - which would change WritingSystemDefinitions
            // and not be allowed in a foreach loop
            var allDefs = AllWritingSystems.Where(CanSet).ToList();

            foreach (var ws in allDefs)
            {
                SaveDefinition(ws);
                OnChangeNotifySharedStore(ws);
            }


            LoadIdChangeMapFromExistingWritingSystems();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves this instance.
        /// </summary>
        public override void Save()
        {
            foreach (string id in AllWritingSystems.Where(ws => ws.MarkedForDeletion).Select(ws => ws.Id).ToArray())
            {
                Remove(id);
            }

            foreach (CoreWritingSystemDefinition ws in AllWritingSystems.Where(CanSet).ToArray())
            {
                Set(ws);
                ws.AcceptChanges();
                OnChangeNotifySharedStore(ws);
            }

            base.Save();
        }
 public override string WritingSystemIdHasChangedTo(string id)
 {
     return(AllWritingSystems.Any(ws => ws.Id.Equals(id)) ? id : _changeLog.GetChangeFor(id));
 }
 private IWritingSystemDefinition FindAlreadyLoadedWritingSystem(string bcp47Tag)
 {
     return(AllWritingSystems.FirstOrDefault(ws => ws.Bcp47Tag == bcp47Tag));
 }