/// <summary> /// Gets the specified writing system if it exists, otherwise it creates /// a writing system using the specified identifier and sets it. /// </summary> /// <param name="identifier">The identifier.</param> /// <param name="ws">The writing system.</param> /// <returns><c>true</c> if identifier is valid (and created); /// <c>false</c> otherwise</returns> public bool TryGetOrSet(string identifier, out IWritingSystem ws) { lock (m_syncRoot) { ws = null; //if (LangTagUtils.IsScriptCodeValid(identifier)) if (Exists(identifier) || (m_globalStore != null && m_globalStore.Contains(identifier))) { GetOrSet(identifier, out ws); if (ws != null) { return(true); } } return(false); } }
/// <summary> /// Determines if a writing system exists with the specified RFC5646 identifier. /// </summary> /// <param name="identifier">The identifier.</param> /// <returns></returns> public bool Exists(string identifier) { lock (m_syncRoot) { var fExists = m_localStore.Contains(identifier); if (!fExists) { if (identifier.StartsWith("cmn")) { var ident = identifier.Remove(0, 3).Insert(0, "zh"); fExists = m_localStore.Contains(ident); if (!fExists && identifier.StartsWith("cmn")) { ident = ident.Insert(2, "-CN"); fExists = m_localStore.Contains(ident); } } else if (identifier.StartsWith("zh")) { var ident = identifier.Insert(2, "-CN"); fExists = m_localStore.Contains(ident); } else if (identifier.StartsWith("pes")) { var ident = identifier.Remove(0, 3).Insert(0, "fa"); fExists = m_localStore.Contains(ident); } else if (identifier.StartsWith("zlm")) { var ident = identifier.Remove(0, 3).Insert(0, "ms"); fExists = m_localStore.Contains(ident); } else if (identifier.StartsWith("arb")) { var ident = identifier.Remove(2, 1); // changes to "ar" fExists = m_localStore.Contains(ident); } } return(fExists); } }
/// <summary> /// /// </summary> /// <param name="ws">The ws.</param> protected override void OnChangeNotifySharedStore(IWritingSystemDefinition ws) { base.OnChangeNotifySharedStore(ws); if (m_globalStore != null) { if (m_globalStore.Contains(ws.Id)) { if (ws.DateModified > m_globalStore.Get(ws.Id).DateModified) { WritingSystemDefinition newWs = ws.Clone(); newWs.Modified = true; m_globalStore.Remove(ws.Id); m_globalStore.Set(newWs); } } else { m_globalStore.Set(ws.Clone()); } } }