Exemple #1
0
        public DbCache(IDbCacheCore <K, T, I> core)
        {
            m_Core = core;
            m_Core.FlushEntities += (s, e) => Flush();

            m_Index = new DbIndex <K, T>(core);
            m_Info  = new Dictionary <K, I>();

            Add(m_Core.RetrieveInitialEntities());
        }
Exemple #2
0
        public DbView(IDbIndexCore <K, T> core, IDbIndex <K, T> index, Func <T, bool> filter, Func <T, T, int> comparer)
        {
            m_Core   = core;
            m_Index  = index;
            m_Filter = filter;

            m_List = new SortedList <T, T>(new EntityComparer <T>(comparer));

            foreach (T item in index)
            {
                if (m_Filter == null || m_Filter(item))
                {
                    lock (m_List)
                    {
                        m_Keys.Add(m_Core.ExtractKey(item));
                        InsertItem(item);
                    }
                }
            }

            m_Index.IndexChanged += OnSourceIndexChanged;
            m_Index.IndexCleared += OnSourceIndexCleared;
        }
Exemple #3
0
 public DbView(IDbIndexCore <K, T> core, IDbIndex <K, T> index, Func <T, T, int> comparer)
     : this(core, index, null, comparer)
 {
 }
Exemple #4
0
 public DbView(IDbIndexCore <K, T> core, IDbIndex <K, T> index, Func <T, bool> filter)
     : this(core, index, filter, null)
 {
 }
Exemple #5
0
 public bool Remove(IDbIndex <T> item)
 {
     return(_base.Remove(item));
 }
Exemple #6
0
 public bool Contains(IDbIndex <T> item)
 {
     return(_base.Contains(item));
 }
Exemple #7
0
 public void Add(IDbIndex <T> item)
 {
     _base.Add(item);
 }