protected void RemoveNamedTag(object key, Hashtable value) { if (value != null) { string str = value["type"] as string; Hashtable hashtable = value["named-tags-list"] as Hashtable; List <string> list = new List <string>(); foreach (string str2 in hashtable.Keys) { if (hashtable[str2] is string) { list.Add(str2); } } foreach (string str3 in list) { hashtable[str3] = (hashtable[str3] as string).ToLower(); } if (base.IndexMapInternal.ContainsKey(str)) { IQueryIndex index = base.IndexMapInternal[str] as IQueryIndex; index.RemoveFromIndex(key, hashtable); if (((AttributeIndex)index).Size == 0) { base.IndexMapInternal.Remove(str); } } } }
public virtual Hashtable GetQueryInfo(object key, object value) { Hashtable queryInfo = new Hashtable(); Hashtable queryIndex = new Hashtable(); CacheEntry entry = (CacheEntry)value; if (entry.ObjectType == null) { return(queryInfo); } IQueryIndex index = (IQueryIndex)_indexMap[entry.ObjectType]; IndexInformation indexInformation = _cache.GetInternal(key).IndexInfo; if (_typeMap != null) { int handleId = _typeMap.GetHandleId(entry.ObjectType); if (handleId > -1) { ArrayList attributes = _typeMap.GetAttribList(handleId); ArrayList attributeValues = new ArrayList(); for (int i = 0; i < attributes.Count; i++) { foreach (IndexStoreInformation indexStoreInfo in indexInformation.IndexStoreInformations) { if (attributes[i].ToString() == indexStoreInfo.StoreName) { if (indexStoreInfo.IndexPosition == null) { attributeValues.Add(null); } else { object val = indexStoreInfo.IndexPosition.GetKey(); string objValue = null; if (val is DateTime) { objValue = ((DateTime)val).Ticks.ToString(); } else { objValue = val.ToString(); } attributeValues.Add(objValue); } break; } } } queryIndex.Add(handleId, attributeValues); queryInfo["query-info"] = queryIndex; } } return(queryInfo); }
public void Clear() { if (_indexMap != null) { lock (_indexMap.SyncRoot) { IDictionaryEnumerator e = _indexMap.GetEnumerator(); while (e.MoveNext()) { IQueryIndex index = e.Value as IQueryIndex; index.Clear(); } this._queryIndexMemorySize = 0; } } }
public virtual void RemoveFromIndex(object key, object value) { if (value == null) { return; } CacheEntry entry = (CacheEntry)value; string type = entry.ObjectType; lock (_indexMap.SyncRoot) { IQueryIndex index = (IQueryIndex)_indexMap[type]; long prevSize = index.IndexInMemorySize; index.RemoveFromIndex(key, value); this._queryIndexMemorySize += index.IndexInMemorySize - prevSize; } }
public virtual void RemoveFromIndex(object key, string value) { if (value == null) { return; } lock (_indexMap.SyncRoot) { string type = value.ToString(); if (_indexMap.Contains(type)) { IQueryIndex index = (IQueryIndex)_indexMap[type]; long prevSize = index.IndexInMemorySize; index.RemoveFromIndex(key); this._queryIndexMemorySize += index.IndexInMemorySize - prevSize; } } }
/// <summary> /// Adiciona uma tag para a instancia. /// </summary> /// <param name="key"></param> /// <param name="value"></param> private void AddTag(object key, Hashtable value) { if (value != null) { string str = value["type"] as string; ArrayList list = value["tags-list"] as ArrayList; if (!base.IndexMapInternal.ContainsKey(str)) { base.IndexMapInternal[str] = new AttributeIndex(null, base._cacheName); } IQueryIndex index = base.IndexMapInternal[str] as IQueryIndex; foreach (string str2 in list) { Hashtable hashtable = new Hashtable(); hashtable["$Tag$"] = str2.ToLower(); index.AddToIndex(key, hashtable); } } }
/// <summary> /// Remove a tag do gerenciador. /// </summary> /// <param name="key"></param> /// <param name="value"></param> private void RemoveTag(object key, Hashtable value) { if (value != null) { string str = value["type"] as string; var list = value["tags-list"] as ArrayList; if (base.IndexMapInternal.ContainsKey(str)) { IQueryIndex index = base.IndexMapInternal[str] as IQueryIndex; foreach (string str2 in list) { Hashtable hashtable = new Hashtable(); hashtable["$Tag$"] = str2.ToLower(); index.RemoveFromIndex(key, hashtable); } if (((AttributeIndex)index).Size == 0) { base.IndexMapInternal.Remove(str); } } } }
public virtual void AddToIndex(object key, object value, OperationContext operationContext) { CacheEntry entry = (CacheEntry)value; if (entry == null) { return; } Hashtable queryInfo = entry.QueryInfo["query-info"] as Hashtable; if (queryInfo == null) { return; } lock (_indexMap.SyncRoot) { IDictionaryEnumerator queryInfoEnumerator = queryInfo.GetEnumerator(); while (queryInfoEnumerator.MoveNext()) { int handleId = (int)queryInfoEnumerator.Key; string type = _typeMap.GetTypeName(handleId); if (_indexMap.Contains(type)) { Hashtable indexAttribs = new Hashtable(); Hashtable metaInfoAttribs = new Hashtable(); ArrayList values = (ArrayList)queryInfoEnumerator.Value; ArrayList attribList = _typeMap.GetAttribList(handleId); for (int i = 0; i < attribList.Count; i++) { string attribute = attribList[i].ToString(); string val = _typeMap.GetAttributes(handleId)[attribList[i]] as string; Type t1 = Type.GetType(val, true, true); object obj = null; if (values[i] != null) { try { if (t1 == typeof(System.DateTime)) { obj = new DateTime(Convert.ToInt64(values[i])); } else { obj = Convert.ChangeType(values[i], t1); } } catch (Exception) { throw new System.FormatException("Cannot convert '" + values[i] + "' to " + t1.ToString()); } indexAttribs.Add(attribute, obj); } else { indexAttribs.Add(attribute, null); } metaInfoAttribs.Add(attribute, obj); } entry.ObjectType = _typeMap.GetTypeName(handleId); IQueryIndex index = (IQueryIndex)_indexMap[type]; long prevSize = index.IndexInMemorySize; index.AddToIndex(key, new QueryItemContainer(entry, indexAttribs)); this._queryIndexMemorySize += index.IndexInMemorySize - prevSize; } } } }
public virtual Hashtable GetQueryInfo(object key, object value) { Hashtable queryInfo = new Hashtable(); Hashtable queryIndex = new Hashtable(); Hashtable namedTagInfo = new Hashtable(); Hashtable namedTagsList = new Hashtable(); Hashtable tagInfo = new Hashtable(); ArrayList tagsList = new ArrayList(); CacheEntry entry = (CacheEntry)value; if (entry.ObjectType == null) { return(queryInfo); } IQueryIndex index = (IQueryIndex)_indexMap[entry.ObjectType]; IndexInformation indexInformation = entry.IndexInfo; lock (_indexMap.SyncRoot) { if (indexInformation != null) { if (_typeMap != null) { int handleId = _typeMap.GetHandleId(entry.ObjectType); if (handleId > -1) { ArrayList attributes = _typeMap.GetAttribList(handleId); ArrayList attributeValues = new ArrayList(); for (int i = 0; i < attributes.Count; i++) { foreach (IndexStoreInformation indexStoreInfo in indexInformation.IndexStoreInformations) { if (attributes[i].ToString() == indexStoreInfo.StoreName) { if (indexStoreInfo.IndexPosition == null) { attributeValues.Add(null); } else { object val = indexStoreInfo.IndexPosition.GetKey(); string objValue = null; if (val is DateTime) { objValue = ((DateTime)val).Ticks.ToString(); } else { objValue = val.ToString(); } attributeValues.Add(objValue); } break; } } } queryIndex.Add(handleId, attributeValues); queryInfo["query-info"] = queryIndex; } } } if (indexInformation != null) { foreach (IndexStoreInformation indexStoreinfo in indexInformation.IndexStoreInformations) { if (AttributeIndex.IsNamedTagKey(indexStoreinfo.StoreName)) { if (indexStoreinfo.IndexPosition != null) { namedTagsList.Add(ConvertToNamedTag(indexStoreinfo.StoreName.ToString()), indexStoreinfo.IndexPosition.GetKey()); } } else if (indexStoreinfo.StoreName.Equals(TAG_INDEX_KEY)) { if (indexStoreinfo.IndexPosition != null) { tagsList.Add(indexStoreinfo.IndexPosition.GetKey()); } } } } namedTagInfo["type"] = entry.ObjectType; namedTagInfo["named-tags-list"] = namedTagsList; queryInfo["named-tag-info"] = namedTagInfo; tagInfo["type"] = entry.ObjectType; tagInfo["tags-list"] = tagsList; queryInfo["tag-info"] = tagInfo; } return(queryInfo); }
public virtual void RemoveFromIndex(object key, object value) { if (value != null && ((Hashtable)value).Contains("query-info")) { value = ((Hashtable)value)["query-info"]; } else { return; } lock (_indexMap.SyncRoot) { IDictionaryEnumerator queryInfoDic = ((Hashtable)value).GetEnumerator(); while (queryInfoDic.MoveNext()) { int handleId = (int)queryInfoDic.Key; string type = _typeMap.GetTypeName(handleId); if (_indexMap.Contains(type)) { Hashtable attribs = new Hashtable(); ArrayList values = (ArrayList)queryInfoDic.Value; ArrayList attribList = _typeMap.GetAttribList(handleId); for (int i = 0; i < attribList.Count; i++) { string val = _typeMap.GetAttributes(handleId)[attribList[i]] as string; Type t1 = Type.GetType(val, true, true); object obj = null; if (values[i] != null) { try { if (t1 == typeof(System.DateTime)) { obj = new DateTime(Convert.ToInt64(values[i])); } else { obj = Convert.ChangeType(values[i], t1); } } catch (Exception) { throw new System.FormatException("Cannot convert '" + values[i] + "' to " + t1.ToString()); } string attribute = attribList[i].ToString(); if (obj != null && obj is string) { attribs.Add(attribute, ((string)obj).ToLower()); } else { attribs.Add(attribute, obj); } } } IQueryIndex index = (IQueryIndex)_indexMap[type]; long prevSize = index.IndexInMemorySize; index.RemoveFromIndex(key, attribs); this._queryIndexMemorySize += index.IndexInMemorySize - prevSize; } } } }