Beispiel #1
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="value">更新后的数据</param>
        /// <param name="oldValue">更新前的数据</param>
        protected void onUpdated(valueType cacheValue, valueType value, valueType oldValue, fastCSharp.code.memberMap <modelType> memberMap)
        {
            int index = getIndex(value), oldIndex = getIndex(oldValue);

            if (index == oldIndex)
            {
                sortType sortKey = getSort(value), oldSortKey = getSort(oldValue);
                if (!sortKey.Equals(oldSortKey))
                {
                    fastCSharp.searchTree <sortType, valueType> tree = array[index].Value;
                    if (tree != null)
                    {
                        ++array[index].Version;
                        try
                        {
                            if (tree.Remove(oldSortKey))
                            {
                                tree.Add(sortKey, cacheValue);
                                return;
                            }
                        }
                        finally { ++array[index].Version; }
                    }
                    log.Error.Add(typeof(valueType).FullName + " 缓存同步错误", null, true);
                }
            }
            else
            {
                onInserted(cacheValue, index);
                onDeleted(oldValue, oldIndex);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 重新加载数据
 /// </summary>
 protected virtual void reset()
 {
     fastCSharp.searchTree <sortType, valueType> newTree = new fastCSharp.searchTree <sortType, valueType>();
     foreach (valueType value in cache.Values)
     {
         newTree.Add(getSort(value), value);
     }
     tree = newTree;
 }
Beispiel #3
0
 /// <summary>
 /// 重新加载数据
 /// </summary>
 protected override void reset()
 {
     fastCSharp.searchTree <sortType, valueType> newTree = new fastCSharp.searchTree <sortType, valueType>();
     foreach (valueType value in cache.Values)
     {
         if (isValue(value))
         {
             newTree.Add(getSort(value), value);
         }
     }
     tree = newTree;
 }
Beispiel #4
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <param name="value">数据对象</param>
 protected virtual void onInserted(valueType value)
 {
     tree.Add(getSort(value), value);
 }