public SynchronizedViewItemRefresher(LocalRecordStore store)
        {
            if (store == null)
            {
                throw new ArgumentNullException("store");
            }

            m_store        = store;
            m_updateChunks = new List <UpdateChunk>();
            m_maxBatchSize = SynchronizedView.DefaultReadAheadChunkSize;
            m_keyBatch     = new List <ViewKey>();
            m_typeVersions = new HashSet <string>();
        }
        LocalRecordStore GetRecordStoreObjectIfExists(IRecord record)
        {
            lock (m_recordStores)
            {
                LocalRecordStore recordStore = null;
                if (record != null && m_recordStores.TryGetValue(record.ID, out recordStore))
                {
                    return(recordStore);
                }

                return(null);
            }
        }
 LocalRecordStore EnsureRecordStoreObject(IRecord record)
 {
     lock (m_recordStores)
     {
         LocalRecordStore recordStore = null;
         if (!m_recordStores.TryGetValue(record.ID, out recordStore))
         {
             recordStore = new LocalRecordStore(record, m_root, this);
             m_recordStores[record.ID] = recordStore;
         }
         return(recordStore);
     }
 }
Example #4
0
        internal SynchronizedTypeManager(LocalRecordStore recordStore)
        {
            if (recordStore == null)
            {
                throw new ArgumentNullException("recordStore");
            }

            m_lock        = new CrossThreadLock(false);
            m_recordStore = recordStore;
            m_views       = new Dictionary <string, WeakReference <SynchronizedType> >();

            m_recordStore.Data.Changes.SynchronizedTypes = this;
            this.ImmediateCommitEnabled = true;
        }
        internal SynchronizedTypeManager(LocalRecordStore recordStore)
        {
            if (recordStore == null)
            {
                throw new ArgumentNullException("recordStore");
            }
            
            m_lock = new CrossThreadLock(false);
            m_recordStore = recordStore;
            m_views = new Dictionary<string,WeakReference<SynchronizedType>>();

            m_recordStore.Data.Changes.SynchronizedTypes = this;
            this.ImmediateCommitEnabled = true;
        }
        bool RemoveRecordStoreObject(string recordID)
        {
            lock (m_recordStores)
            {
                LocalRecordStore store = null;
                if (m_recordStores.TryGetValue(recordID, out store) && store != null)
                {
                    store.Data.Changes.IsCommitEnabled = false;
                    m_recordStores.Remove(recordID);
                    return(true);
                }

                return(false);
            }
        }
        internal void ResetRecordObjects(UserInfo userInfo)
        {
            lock (m_recordStores)
            {
                if (userInfo == null)
                {
                    throw new ArgumentNullException("userInfo");
                }

                foreach (IRecord record in userInfo.AuthorizedRecords)
                {
                    LocalRecordStore recordStore = null;
                    if (m_recordStores.TryGetValue(record.ID, out recordStore))
                    {
                        recordStore.Record = record;
                    }
                }
            }
        }
        public IAsyncAction CommitChangesAsync()
        {
            return(AsyncInfo.Run(async cancelToken =>
            {
                IRecord[] records = this.GetAllRecords();

                using (await CrossThreadLockScope.Enter(m_storageLock))
                {
                    foreach (IRecord record in records)
                    {
                        LocalRecordStore store = this.GetRecordStoreObjectIfExists(record);
                        if (store != null)
                        {
                            await store.Data.CommitChangesAsync(cancelToken);
                        }
                    }
                }
            }));
        }
        public LocalRecordStore GetStoreForRecord(IRecord record)
        {
            if (record == null)
            {
                throw new ArgumentException(null);
            }

            lock (m_recordStores)
            {
                LocalRecordStore recordStore = null;
                string recordID = record.ID;
                if (!m_recordStores.TryGetValue(recordID, out recordStore))
                {
                    recordStore = new LocalRecordStore(record, m_root, this);
                    m_recordStores[recordID] = recordStore;
                }

                recordStore.Record = record;
                return recordStore;
            }
        }
        public IAsyncOperation <bool> HasChangesAsync()
        {
            return(AsyncInfo.Run(async cancelToken =>
            {
                IRecord[] records = this.GetAllRecords();

                using (await CrossThreadLockScope.Enter(m_storageLock))
                {
                    foreach (IRecord record in records)
                    {
                        LocalRecordStore store = this.GetRecordStoreObjectIfExists(record);
                        if (store != null && await store.Data.HasChangesAsync())
                        {
                            return true;
                        }
                    }
                }

                return false;
            }));
        }
 LocalRecordStore EnsureRecordStoreObject(IRecord record)
 {
     lock (m_recordStores)
     {
         LocalRecordStore recordStore = null;
         if (!m_recordStores.TryGetValue(record.ID, out recordStore))
         {
             recordStore = new LocalRecordStore(record, m_root, this);
             m_recordStores[record.ID] = recordStore;
         }
         return recordStore;
     }
 }