Exemplo n.º 1
0
        /// <summary>
        /// Replaces an existing writing system with the specified writing system if they
        /// have the same identifier.
        /// </summary>
        /// <param name="ws">The writing system.</param>
        public void Replace(IWritingSystem ws)
        {
            var palasoWs = (PalasoWritingSystem)ws;

            lock (m_syncRoot)
            {
                IWritingSystem existingWs;
                if (TryGet(palasoWs.Id, out existingWs))
                {
                    if (existingWs == palasoWs)
                    {
                        // don't do anything
                        return;
                    }

                    m_handleWss.Remove(existingWs.Handle);
                    m_localStore.Remove(existingWs.Id);
                    m_localStore.Set(palasoWs);
                    palasoWs.WritingSystemManager = this;
                    palasoWs.Handle = existingWs.Handle;
                    m_handleWss[palasoWs.Handle] = palasoWs;
                }
                else
                {
                    Set(ws);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ws">The ws.</param>
        protected override void OnChangeNotifySharedStore(WritingSystemDefinition ws)
        {
            base.OnChangeNotifySharedStore(ws);

            if (m_globalStore != null)
            {
                WritingSystemDefinition globalWs;
                if (m_globalStore.TryGet(ws.Id, out globalWs))
                {
                    if (ws.DateModified > globalWs.DateModified)
                    {
                        WritingSystemDefinition newWs = ws.Clone();
                        newWs.Modified = true;
                        try
                        {
                            m_globalStore.Remove(ws.Id);
                            m_globalStore.Set(newWs);
                        }
                        catch (UnauthorizedAccessException)
                        {
                            // Live with it if we can't update the global store. In a CS world we might
                            // well not have permission.
                        }
                    }
                }

                else
                {
                    m_globalStore.Set(ws.Clone());
                }
            }
        }
Exemplo n.º 3
0
        /// <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());
                }
            }
        }