Пример #1
0
        /// <summary>
        /// Método acioando quando um novo manipulador for adicionado.
        /// </summary>
        /// <param name="handleId"></param>
        private void TypeMap_HandleAdded(int handleId)
        {
            var type       = _typeMap.GetTypeName(handleId);
            var attributes = _typeMap.GetAttribList(handleId);

            if (attributes.Count > 0)
            {
                _indexMap[type] = new AttributeIndex(attributes, _cacheName);
            }
            else
            {
                _indexMap[type] = new TypeIndex(type, _indexForAll);
            }
        }
Пример #2
0
        /// <summary>
        /// Inicializa a instancia.
        /// </summary>
        /// <returns></returns>
        internal virtual bool Initialize()
        {
            bool flag = false;

            if (_props != null)
            {
                if (_props.Contains("index-for-all"))
                {
                    _indexForAll = Convert.ToBoolean(_props["index-for-all"]);
                    flag         = _indexForAll;
                }
                if (_props.Contains("index-classes"))
                {
                    Hashtable indexClasses = _props["index-classes"] as Hashtable;
                    _typeMap = new TypeInfoMap(indexClasses);
                    IDictionaryEnumerator enumerator = indexClasses.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        Hashtable hashtable2 = enumerator.Value as Hashtable;
                        string    type       = "";
                        if (hashtable2 != null)
                        {
                            type = (string)hashtable2["id"];
                            var attributes = new List <string>();
                            IDictionaryEnumerator enumerator2 = hashtable2.GetEnumerator();
                            while (enumerator2.MoveNext())
                            {
                                Hashtable hashtable3 = enumerator2.Value as Hashtable;
                                if (hashtable3 != null)
                                {
                                    IDictionaryEnumerator enumerator3 = hashtable3.GetEnumerator();
                                    while (enumerator3.MoveNext())
                                    {
                                        Hashtable hashtable4 = enumerator3.Value as Hashtable;
                                        if (hashtable4 != null)
                                        {
                                            attributes.Add(hashtable4["id"] as string);
                                        }
                                    }
                                }
                            }
                            if (attributes.Count > 0)
                            {
                                _indexMap[type] = new AttributeIndex(attributes, _cacheName);
                            }
                            else
                            {
                                _indexMap[type] = new TypeIndex(type, _indexForAll);
                            }
                            flag = true;
                        }
                    }
                }
                else
                {
                    _typeMap = new TypeInfoMap(new Hashtable());
                }
            }
            else
            {
                _indexMap["default"] = new VirtualQueryIndex(_cache);
                _typeMap             = new TypeInfoMap(new Hashtable());
            }
            _typeMap.HandleAdded += new Action <int>(TypeMap_HandleAdded);
            if (flag)
            {
                _asyncProcessor = new AsyncProcessor("Cache.QueryIndexManager", _cache.Context.Logger);
                _asyncProcessor.Start();
            }
            return(flag);
        }