/// <summary> /// Verifica se existem itens com o nome publicados. /// </summary> /// <param name="value">Instancia.</param> /// <param name="namedTags">Dicionário com as tags nomeadas.</param> /// <param name="typeMap"></param> private static void CheckDuplicateIndexName(object value, NamedTagsDictionary namedTags, TypeInfoMap typeMap) { if (namedTags != null && value != null && typeMap != null) { int handleId = 0; if (value is CacheItemRecord) { handleId = typeMap.GetHandleId(((CacheItemRecord)value).TypeName); } else { handleId = typeMap.GetHandleId(value.GetType()); } if (handleId != -1) { foreach (string str2 in typeMap.GetAttribList(handleId)) { if (namedTags.Contains(str2)) { throw new Exception(ResourceMessageFormatter.Create(() => Properties.Resources.Exception_DuplicateIndexName).Format()); } } } } }
private static void CheckDuplicateIndexName(object value, NamedTagsDictionary namedTags, TypeInfoMap typeMap) { if (namedTags == null || value == null || typeMap == null) { return; } string typeName = value.GetType().FullName; typeName = typeName.Replace("+", "."); int handleId = typeMap.GetHandleId(typeName); if (handleId != -1) { ArrayList attributes = typeMap.GetAttribList(handleId); foreach (string name in attributes) { if (namedTags.Contains(name)) //@UH whether this should be case insensitive { throw new Exception("Key in named tags conflicts with the indexed attribute name of the specified object."); } } } }
private static void CheckJavaDuplicateIndexName(string fullName, NamedTagsDictionary namedTags, TypeInfoMap typeMap) { if (namedTags == null || typeMap == null) { return; } string typeName = fullName; typeName = typeName.Replace("+", "."); int handleId = typeMap.GetHandleId(typeName); if (handleId != -1) { ArrayList attributes = typeMap.GetAttribList(handleId); foreach (string name in attributes) { if (namedTags.Contains(name)) { throw new Exception("Key in named tags conflicts with the indexed attribute name of the specified object."); } } } }
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 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); }
internal static Hashtable GetQueryInfo(Object value, TypeInfoMap typeMap) { Hashtable queryInfo = null; if (typeMap == null) { return(null); } try { int handleId = typeMap.GetHandleId(value.GetType().FullName); if (handleId != -1) { queryInfo = new Hashtable(); ArrayList attribValues = new ArrayList(); ArrayList attributes = typeMap.GetAttribList(handleId); for (int i = 0; i < attributes.Count; i++) { PropertyInfo propertyAttrib = value.GetType().GetProperty((string)attributes[i]); if (propertyAttrib != null) { Object attribValue = propertyAttrib.GetValue(value, null); if (attribValue is String) //add all strings as lower case in index tree { attribValue = attribValue.ToString(); //.ToLower(); } if (attribValue is DateTime) //add all DateTime as ticks { attribValue = ((DateTime)(attribValue)).Ticks.ToString(CultureInfo.InvariantCulture); } attribValues.Add(attribValue); } else { BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.Instance; FieldInfo fieldAttrib = value.GetType().GetField((string)attributes[i], flags); if (fieldAttrib != null) { Object attribValue = fieldAttrib.GetValue(value); if (attribValue is String) //add all strings as lower case in index tree { attribValue = attribValue.ToString(); } if (attribValue is DateTime) //add all DateTime as ticks { attribValue = ((DateTime)(attribValue)).Ticks.ToString(CultureInfo.InvariantCulture); } attribValues.Add(attribValue); } else { throw new Exception("Unable extracting query information from user object."); } } } queryInfo.Add(handleId, attribValues); } } catch (Exception) { } return(queryInfo); }
/// <summary> /// Recupera as informações de consulta. /// </summary> /// <param name="value"></param> /// <param name="typeMap"></param> /// <returns></returns> internal static Hashtable GetQueryInfo(object value, TypeInfoMap typeMap) { Hashtable hashtable = null; ArrayList list = null; if (typeMap == null) { return(null); } try { int handleId = -1; if (value is ICacheItemRecord) { var record = (ICacheItemRecord)value; handleId = typeMap.GetHandleId(record.TypeName); if (handleId == -1) { return(hashtable); } hashtable = new Hashtable(); list = new ArrayList(); var attribList = typeMap.GetAttribList(handleId); for (int i = 0; i < attribList.Count; i++) { var fieldIndex = -1; for (int j = 0; j < record.Descriptor.Count; j++) { if (record.Descriptor[j].Name == attribList[i]) { fieldIndex = j; break; } } if (fieldIndex >= 0) { object obj2 = record.GetValue(fieldIndex); if (obj2 is string) { obj2 = obj2.ToString().ToLower(); } else if (obj2 is DateTime) { DateTime time = (DateTime)obj2; obj2 = time.Ticks.ToString(); } list.Add(obj2); } else { list.Add(null); } } } else { handleId = typeMap.GetHandleId(value.GetType()); if (handleId == -1) { return(hashtable); } hashtable = new Hashtable(); list = new ArrayList(); var attribList = typeMap.GetAttribList(handleId); for (int i = 0; i < attribList.Count; i++) { var property = value.GetType().GetProperty(attribList[i]); if (property != null) { object obj2 = property.GetValue(value, null); if (obj2 is string) { obj2 = obj2.ToString().ToLower(); } if (obj2 is DateTime) { DateTime time = (DateTime)obj2; obj2 = time.Ticks.ToString(); } list.Add(obj2); } else { var field = value.GetType().GetField((string)attribList[i]); if (field == null) { throw new Exception("Unable extracting query information from user object."); } object obj3 = field.GetValue(value); if (obj3 is string) { obj3 = obj3.ToString().ToLower(); } if (obj3 is DateTime) { DateTime time2 = (DateTime)obj3; obj3 = time2.Ticks.ToString(); } list.Add(obj3); } } } hashtable.Add(handleId, list); } catch (Exception ex) { System.Diagnostics.Debug.Fail("An error ocurred when get query info", Colosoft.Diagnostics.ExceptionFormatter.FormatException(ex, true)); throw; } return(hashtable); }