Пример #1
0
 /// <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);
         }
     }
 }
Пример #2
0
        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;
                    }
                }
            }
        }