public void FindIndex(string indexKey, object[] propertyValues, Action <string> action) { EntityIndexList indexList = new EntityIndexList(); if (_entityIndexDict != null && _entityIndexDict.ContainsKey(indexKey) && _entityIndexDict[indexKey] != null) { indexList = _entityIndexDict[indexKey]; } string indexItemKey = BaseEntity.CreateKeyCode(propertyValues); EntityIndex entityIndex = indexList[indexItemKey];//当没有indexKey对应键值时,entityIndex为空 if (entityIndex != null) { entityIndex.Foreach(action); } //TraceLog.Write("获得索引对象为空,缓存实体类:{0},索引键:{1},字典项Key:{2},字典容量:{3}",_cachekey, indexKey, indexItemKey, indexList.Count); }
/// <summary> /// 移除索引器 /// </summary> /// <param name="propertyValues"></param> /// <param name="indexValue"></param> internal void Remove(object[] propertyValues, string indexValue) { EntityIndex entityIndex = new EntityIndex(propertyValues); string indexItemKey = entityIndex.GetKeyCode(); if (_entityIndexDict.ContainsKey(indexItemKey)) { entityIndex = _entityIndexDict[indexItemKey]; } entityIndex.Remove(indexValue); if (_entityIndexDict.ContainsKey(indexItemKey)) { _entityIndexDict[indexItemKey] = entityIndex; } else { _entityIndexDict.Add(indexItemKey, entityIndex); } }
/// <summary> /// 增加索引器 /// </summary> /// <param name="propertyValues"></param> /// <param name="indexValue"></param> internal void Add(object[] propertyValues, string indexValue) { EntityIndex entityIndex = new EntityIndex(propertyValues); string indexItemKey = entityIndex.GetKeyCode(); if (_entityIndexDict.ContainsKey(indexItemKey)) { entityIndex = _entityIndexDict[indexItemKey]; } entityIndex.Add(indexValue); if (_entityIndexDict.ContainsKey(indexItemKey)) { _entityIndexDict[indexItemKey] = entityIndex; } else { _entityIndexDict.Add(indexItemKey, entityIndex); } }