protected virtual void OnChangeNotifySharedStore(T ws) { DateTime lastDateModified; if (_writingSystemsToIgnore.TryGetValue(ws.LanguageTag, out lastDateModified) && ws.DateModified > lastDateModified) { _writingSystemsToIgnore.Remove(ws.LanguageTag); } if (_globalRepository != null) { T globalWs; if (_globalRepository.TryGet(ws.LanguageTag, out globalWs)) { if (ws.DateModified > globalWs.DateModified) { T newWs = WritingSystemFactory.Create(ws, cloneId: true); try { _globalRepository.Replace(ws.LanguageTag, newWs); } catch (Exception) { // Live with it if we can't update the global store. In a CS world we might // well not have permission. } } } else { _globalRepository.Set(WritingSystemFactory.Create(ws, cloneId: true)); } } }
/// <summary> /// Gets the specified writing system. Throws KeyNotFoundException if it cannot be found, /// there is a TryGet available to avoid this. /// </summary> /// <exception cref="KeyNotFoundException"></exception> /// <param name="identifier">The identifier.</param> /// <returns></returns> public CoreWritingSystemDefinition Get(string identifier) { lock (m_syncRoot) { WritingSystemDefinition wrsys; if (!m_repo.TryGet(identifier, out wrsys)) { throw new KeyNotFoundException("The writing system " + identifier + " was not found in this manager."); } return((CoreWritingSystemDefinition)wrsys); } }
/// <summary> /// Resets any property values that were removed during migration so that they are not lost. /// </summary> public void ResetRemovedProperties(IWritingSystemRepository repo) { foreach (KeyValuePair<string, List<Action<WritingSystemDefinition>>> kvp in _removedPropertiesSetters) { WritingSystemDefinition ws; if (repo.TryGet(kvp.Key, out ws)) { foreach (Action<WritingSystemDefinition> setter in kvp.Value) setter(ws); } } repo.Save(); }
/// <summary> /// Resets any property values that were removed during migration so that they are not lost. /// </summary> public void ResetRemovedProperties(IWritingSystemRepository repo) { foreach (KeyValuePair <string, List <Action <WritingSystemDefinition> > > kvp in _removedPropertiesSetters) { WritingSystemDefinition ws; if (repo.TryGet(kvp.Key, out ws)) { foreach (Action <WritingSystemDefinition> setter in kvp.Value) { setter(ws); } } } repo.Save(); }