예제 #1
0
        /// <summary>
        /// 分组列表缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="getIndex">获取数组索引</param>
        /// <param name="arraySize">数组容器大小</param>
        /// <param name="member">缓存字段表达式</param>
        /// <param name="isRemoveEnd">移除数据并使用最后一个数据移动到当前位置</param>
        /// <param name="isReset">是否绑定事件并重置数据</param>
        public memberArrayList(events.cache <valueType, modelType> cache
                               , Func <modelType, keyType> getKey, Func <valueType, int> getIndex, int arraySize
                               , Func <keyType, targetType> getValue, Expression <Func <targetType, list <valueType>[]> > member
                               , Func <IEnumerable <targetType> > getTargets, bool isRemoveEnd, bool isReset = true)
            : base(cache, getKey, getValue, member, getTargets)
        {
            if (getIndex == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            if (arraySize <= 0)
            {
                log.Error.Throw(log.exceptionType.IndexOutOfRange);
            }
            this.getIndex    = getIndex;
            this.arraySize   = arraySize;
            this.isRemoveEnd = isRemoveEnd;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #2
0
        /// <summary>
        /// 缓存时间事件
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getTime">时间获取器</param>
        /// <param name="run">事件委托</param>
        /// <param name="isValue">数据匹配器</param>
        public timerWhere(events.cache <valueType, modelType> cache, Func <valueType, DateTime> getTime, Action run, Func <valueType, bool> isValue)
            : base(cache, getTime, run, false)
        {
            if (isValue == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.isValue = isValue;

            cache.OnReset    += reset;
            cache.OnInserted += onInserted;
            cache.OnUpdated  += onUpdated;
            resetLock();
        }
예제 #3
0
        /// <summary>
        /// 分组列表缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组关键字获取器</param>
        /// <param name="getSort">排序关键字获取器</param>
        /// <param name="isValue">缓存值判定</param>
        public dictionarySearchTreeWhere(events.cache <valueType, modelType, memberCacheType> cache, Func <valueType, keyType> getKey, Func <valueType, sortType> getSort, Func <valueType, bool> isValue)
            : base(cache, getKey, getSort, false)
        {
            if (isValue == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.isValue = isValue;

            cache.OnReset    += reset;
            cache.OnInserted += onInserted;
            cache.OnUpdated  += onUpdated;
            cache.OnDeleted  += onDeleted;
            resetLock();
        }
예제 #4
0
        /// <summary>
        /// 分组列表缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getIndex">数组索引获取器</param>
        /// <param name="arraySize">数组容器大小</param>
        /// <param name="getSort">排序关键字获取器</param>
        /// <param name="isValue">缓存值判定</param>
        public arraySearchTreeWhere(events.cache <valueType, modelType> cache, Func <valueType, int> getIndex, int arraySize, Func <valueType, sortType> getSort, Func <valueType, bool> isValue)
            : base(cache, getIndex, arraySize, getSort, false)
        {
            if (isValue == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.isValue = isValue;

            cache.OnReset    += reset;
            cache.OnInserted += onInserted;
            cache.OnUpdated  += onUpdated;
            cache.OnDeleted  += onDeleted;
            resetLock();
        }
예제 #5
0
        /// <summary>
        /// 分组列表缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="getValue">获取目标对象委托</param>
        /// <param name="member">缓存字段表达式</param>
        /// <param name="getTargets">获取缓存目标对象集合</param>
        /// <param name="isRemoveEnd">移除数据并使用最后一个数据移动到当前位置</param>
        /// <param name="isReset">是否绑定事件并重置数据</param>
        public memberList(events.cache <valueType, modelType> cache, Func <modelType, keyType> getKey
                          , Func <keyType, targetType> getValue, Expression <Func <targetType, list <valueType> > > member
                          , Func <IEnumerable <targetType> > getTargets, bool isRemoveEnd = false, bool isReset = true)
            : base(cache, getKey, getValue, member, getTargets)
        {
            this.isRemoveEnd = isRemoveEnd;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #6
0
        /// <summary>
        /// 超时缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="timeOutSeconds">超时秒数</param>
        /// <param name="getTime">时间获取器</param>
        /// <param name="isValue">数据匹配器</param>
        public timeOutOrderLadyWhere(events.cache <valueType, modelType, memberCacheType> cache
                                     , double timeOutSeconds, Func <valueType, DateTime> getTime, Func <valueType, bool> isValue)
            : base(cache, timeOutSeconds, getTime, false)
        {
            if (isValue == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.isValue = isValue;

            cache.OnReset    += reset;
            cache.OnInserted += onInserted;
            cache.OnUpdated  += onUpdated;
            cache.OnDeleted  += onDeleted;
            resetLock();
        }
예제 #7
0
        /// <summary>
        /// 分组字典缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="getValue">获取目标对象委托</param>
        /// <param name="member">缓存字段表达式</param>
        /// <param name="getValueKey">获取数据关键字委托</param>
        /// <param name="isReset">是否绑定事件并重置数据</param>
        public memberDictionaryWhere(events.cache <valueType, modelType> cache, Func <modelType, keyType> getKey
                                     , Func <keyType, targetType> getValue, Expression <Func <targetType, Dictionary <randomKey <valueKeyType>, valueType> > > member
                                     , Func <IEnumerable <targetType> > getTargets, Func <modelType, valueKeyType> getValueKey, Func <valueType, bool> isValue)
            : base(cache, getKey, getValue, member, getTargets, getValueKey, false)
        {
            if (isValue == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.isValue = isValue;

            cache.OnReset    += reset;
            cache.OnInserted += onInserted;
            cache.OnUpdated  += onUpdated;
            cache.OnDeleted  += onDeleted;
            resetLock();
        }
        /// <summary>
        /// 分组列表 延时排序缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="sorter">排序器</param>
        /// <param name="isValue">缓存值判定</param>
        public dictionaryListOrderLadyWhere
            (events.cache <valueType, modelType> cache, Func <modelType, keyType> getKey, Func <list <valueType>, subArray <valueType> > sorter
            , Func <valueType, bool> isValue)
            : base(cache, getKey, sorter, false)
        {
            if (isValue == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.isValue = isValue;

            cache.OnReset    += reset;
            cache.OnInserted += onInserted;
            cache.OnUpdated  += onUpdated;
            cache.OnDeleted  += onDeleted;
            resetLock();
        }
예제 #9
0
        /// <summary>
        /// 字典缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="isReset">是否初始化</param>
        public dictionary(events.cache <valueType, modelType> cache, Func <valueType, keyType> getKey, bool isReset = true)
        {
            if (cache == null || getKey == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.cache  = cache;
            this.getKey = getKey;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #10
0
        /// <summary>
        /// 分组列表缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getSort">排序关键字获取器</param>
        /// <param name="isReset">是否绑定事件与重置数据</param>
        public searchTree(events.cache <valueType, modelType> cache, Func <valueType, sortType> getSort, bool isReset = true)
        {
            if (cache == null || getSort == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.cache   = cache;
            this.getSort = getSort;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #11
0
        /// <summary>
        /// 关键字整表缓存
        /// </summary>
        /// <param name="sqlTool">SQL操作工具</param>
        /// <param name="getKey">键值获取器</param>
        /// <param name="getValue">根据关键字获取数据</param>
        /// <param name="member">缓存字段表达式</param>
        /// <param name="group">数据分组</param>
        public memberKey(cache<valueType, modelType> cache, Func<modelType, keyType> getKey
            , Func<keyType, valueType> getValue, Expression<Func<valueType, valueType>> member, int group = 1)
            : base(cache.SqlTool, null, getKey, group)
        {
            if (getValue == null || member == null) log.Error.Throw(log.exceptionType.Null);
            memberExpression<valueType, valueType> expression = new memberExpression<valueType, valueType>(member);
            if (expression.Field == null) log.Error.Throw(log.exceptionType.ErrorOperation);
            this.cache = cache;
            this.getValue = getValue;
            getMember = expression.GetMember;
            setMember = expression.SetMember;

            cache.SqlTool.OnInsertedLock += onInserted;
            cache.SqlTool.OnUpdatedLock += onUpdated;
            cache.SqlTool.OnDeletedLock += onDeleted;

            resetLock();
        }
예제 #12
0
        /// <summary>
        /// 缓存时间事件
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getTime">时间获取器</param>
        /// <param name="run">事件委托</param>
        /// <param name="isReset">是否绑定事件与重置数据</param>
        public timer(events.cache <valueType, modelType> cache, Func <valueType, DateTime> getTime, Action run, bool isReset)
        {
            if (cache == null || getTime == null || run == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            runTimeHandle = runTime;
            this.cache    = cache;
            this.getTime  = getTime;
            this.run      = run;
            minTime       = DateTime.MaxValue;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                resetLock();
            }
        }
예제 #13
0
        /// <summary>
        /// 分组列表缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getIndex">数组索引获取器</param>
        /// <param name="arraySize">数组容器大小</param>
        /// <param name="isRemoveEnd">移除数据并使用最后一个数据移动到当前位置</param>
        /// <param name="isReset">是否绑定事件并重置数据</param>
        public arrayList(events.cache <valueType, modelType> cache, Func <valueType, int> getIndex, int arraySize, bool isRemoveEnd, bool isReset)
        {
            if (cache == null || getIndex == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            array            = new version <list <valueType> > [arraySize];
            this.cache       = cache;
            this.getIndex    = getIndex;
            this.isRemoveEnd = isRemoveEnd;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #14
0
        /// <summary>
        /// 分组列表 延时排序缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="getValue">获取目标对象委托</param>
        /// <param name="member">缓存字段表达式</param>
        /// <param name="sorter">排序器</param>
        /// <param name="isReset">是否初始化</param>
        public memberLadyOrderArray(events.cache <valueType, modelType> cache, Func <modelType, keyType> getKey
                                    , Func <keyType, targetType> getValue, Expression <Func <targetType, ladyOrderArray <valueType> > > member
                                    , Func <IEnumerable <targetType> > getTargets, Func <subArray <valueType>, subArray <valueType> > sorter, bool isReset)
            : base(cache, getKey, getValue, member, getTargets)
        {
            if (sorter == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            Sorter = sorter;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #15
0
        /// <summary>
        /// 超时缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="timeOutSeconds">超时秒数</param>
        /// <param name="getTime">时间获取器</param>
        /// <param name="isReset">是否绑定事件与重置数据</param>
        public timeOutOrderLady(events.cache <valueType, modelType, memberCacheType> cache
                                , double timeOutSeconds, Func <valueType, DateTime> getTime, bool isReset)
        {
            if (cache == null || timeOutSeconds < 1 || getTime == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.cache          = cache;
            this.timeOutSeconds = -timeOutSeconds;
            this.getTime        = getTime;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #16
0
        /// <summary>
        /// 分组列表 延时排序缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="sorter">排序器</param>
        /// <param name="isReset">是否初始化</param>
        public dictionaryListOrderLady(events.cache <valueType, modelType> cache
                                       , Func <modelType, keyType> getKey, Func <list <valueType>, subArray <valueType> > sorter, bool isReset)
        {
            if (cache == null || getKey == null || sorter == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.cache  = cache;
            this.getKey = getKey;
            this.sorter = sorter;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #17
0
        /// <summary>
        /// 分组列表缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getIndex">数组索引获取器</param>
        /// <param name="getSort">排序关键字获取器</param>
        /// <param name="isReset">是否初始化</param>
        public arraySearchTree
            (events.cache <valueType, modelType> cache, Func <valueType, int> getIndex, int arraySize, Func <valueType, sortType> getSort, bool isReset = true)
        {
            if (cache == null || getIndex == null || getSort == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            array         = new version <fastCSharp.searchTree <sortType, valueType> > [arraySize];
            this.cache    = cache;
            this.getIndex = getIndex;
            this.getSort  = getSort;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #18
0
        /// <summary>
        /// 分组列表缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="isRemoveEnd">移除数据并使用最后一个数据移动到当前位置</param>
        /// <param name="isReset">是否绑定事件并重置数据</param>
        public memberDictionaryList(events.cache <valueType, modelType> cache
                                    , Func <modelType, keyType> getKey, Func <modelType, memberKeyType> getMemberKey
                                    , Func <keyType, targetType> getValue, Expression <Func <targetType, Dictionary <randomKey <memberKeyType>, list <valueType> > > > member
                                    , Func <IEnumerable <targetType> > getTargets, bool isRemoveEnd, bool isReset)
            : base(cache, getKey, getValue, member, getTargets)
        {
            if (getMemberKey == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            this.getMemberKey = getMemberKey;
            this.isRemoveEnd  = isRemoveEnd;

            if (isReset)
            {
                cache.OnReset    += reset;
                cache.OnInserted += onInserted;
                cache.OnUpdated  += onUpdated;
                cache.OnDeleted  += onDeleted;
                resetLock();
            }
        }
예제 #19
0
        /// <summary>
        /// 分组列表缓存
        /// </summary>
        /// <param name="cache">整表缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="getValue">获取目标对象委托</param>
        /// <param name="member">缓存字段表达式</param>
        /// <param name="getTargets">获取缓存目标对象集合</param>
        public member(events.cache <valueType, modelType> cache, Func <modelType, keyType> getKey, Func <keyType, targetType> getValue
                      , Expression <Func <targetType, cacheType> > member, Func <IEnumerable <targetType> > getTargets)
        {
            if (cache == null)
            {
                log.Error.Throw("cache is null", null, false);
            }
            if (getKey == null || getValue == null || getTargets == null || member == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            memberExpression <targetType, cacheType> expression = new memberExpression <targetType, cacheType>(member);

            if (expression.Field == null)
            {
                log.Error.Throw(log.exceptionType.ErrorOperation);
            }
            this.cache      = cache;
            this.getKey     = getKey;
            this.getValue   = getValue;
            this.getTargets = getTargets;
            GetMember       = expression.GetMember;
            setMember       = expression.SetMember;
        }