Esempio n. 1
0
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="parser">参数解析</param>
        internal override void QueryEnd(ref OperationParameter.NodeParser parser)
        {
            switch (parser.OperationType)
            {
            case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(count); return;

            case OperationParameter.OperationType.ContainsKey:
                HashCodeKey <keyType> key;
                if (HashCodeKey <keyType> .Get(ref parser, out key))
                {
                    System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = dictionarys[key.HashCode & 0xff];
                    parser.ReturnParameter.ReturnParameterSet(dictionary != null && dictionary.ContainsKey(key));
                }
                return;

            case OperationParameter.OperationType.CreateShortPath:
                nodeType node = getNext(ref parser);
                if (node != null)
                {
                    node.CreateShortPath(ref parser);
                }
                return;
            }
            parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError;
        }
Esempio n. 2
0
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="parser"></param>
        private void remove(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = dictionarys[key.HashCode & 0xff];
                if (dictionary != null)
                {
                    nodeType node;
                    if (dictionary.TryGetValue(key, out node))
                    {
                        dictionary.Remove(key);
                        --count;
                        parser.SetOperationReturnParameter();
                        node.OnRemoved();
                        return;
                    }
                }
                parser.ReturnParameter.ReturnParameterSet(false);
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
        }
 /// <summary>
 /// 获取下一个节点
 /// </summary>
 /// <param name="parser"></param>
 /// <returns></returns>
 private nodeType getNext(ref OperationParameter.NodeParser parser)
 {
     keyType key;
     if (HashCodeKey<keyType>.Get(ref parser, out key))
     {
         nodeType node;
         if (dictionary.TryGetValue(key, out node)) return node;
         parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey;
     }
     return null;
 }
 /// <summary>
 /// 获取或者创建节点
 /// </summary>
 /// <param name="parser"></param>
 private void getOrCreateNode(ref OperationParameter.NodeParser parser)
 {
     keyType key;
     if (HashCodeKey<keyType>.Get(ref parser, out key))
     {
         if (!dictionary.ContainsKey(key))
         {
             dictionary.Set(key, nodeConstructor(this, ref parser));
             parser.IsOperation = true;
         }
         parser.ReturnParameter.ReturnParameterSet(true);
     }
     else parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
 }
 /// <summary>
 /// 删除节点
 /// </summary>
 /// <param name="parser"></param>
 private void remove(ref OperationParameter.NodeParser parser)
 {
     keyType key;
     if (HashCodeKey<keyType>.Get(ref parser, out key))
     {
         nodeType node;
         if (dictionary.Remove(ref key, out node))
         {
             parser.SetOperationReturnParameter();
             node.OnRemoved();
         }
         else parser.ReturnParameter.ReturnParameterSet(false);
     }
     else parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
 }
Esempio n. 6
0
        /// <summary>
        /// 获取下一个节点
        /// </summary>
        /// <param name="parser"></param>
        /// <returns></returns>
        private nodeType getNext(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                nodeType node;
                if (fragmentDictionary.TryGetValue(key, out node))
                {
                    return(node);
                }
                parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey;
            }
            return(null);
        }
 /// <summary>
 /// 查询数据
 /// </summary>
 /// <param name="parser">参数解析</param>
 internal override void QueryEnd(ref OperationParameter.NodeParser parser)
 {
     switch (parser.OperationType)
     {
         case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(dictionary.Count); return;
         case OperationParameter.OperationType.ContainsKey:
             keyType key;
             if (HashCodeKey<keyType>.Get(ref parser, out key)) parser.ReturnParameter.ReturnParameterSet(dictionary.ContainsKey(key));
             return;
         case OperationParameter.OperationType.CreateShortPath:
             nodeType node = getNext(ref parser);
             if (node != null) node.CreateShortPath(ref parser);
             return;
     }
     parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError;
 }
Esempio n. 8
0
        /// <summary>
        /// 获取下一个节点
        /// </summary>
        /// <param name="parser"></param>
        /// <returns></returns>
        private nodeType getNext(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = dictionarys[key.HashCode & 0xff];
                if (dictionary != null)
                {
                    nodeType node;
                    if (dictionary.TryGetValue(key, out node))
                    {
                        return(node);
                    }
                }
                parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey;
            }
            return(null);
        }
Esempio n. 9
0
        /// <summary>
        /// 获取或者创建节点
        /// </summary>
        /// <param name="parser"></param>
        private void getOrCreateNode(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = fragmentDictionary.GetOrCreateDictionary(key);
                if (!dictionary.ContainsKey(key))
                {
                    dictionary.Add(key, nodeConstructor(this, ref parser));
                    ++fragmentDictionary.Count;
                    parser.IsOperation = true;
                }
                parser.ReturnParameter.ReturnParameterSet(true);
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 获取或者创建节点
        /// </summary>
        /// <param name="parser"></param>
        private void getOrCreateNode(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = dictionarys[key.HashCode & 0xff];
                if (dictionary == null)
                {
                    dictionarys[key.HashCode & 0xff] = dictionary = AutoCSer.DictionaryCreator <HashCodeKey <keyType> > .Create <nodeType>();
                }
                if (!dictionary.ContainsKey(key))
                {
                    dictionary.Add(key, nodeConstructor(this, ref parser));
                    ++count;
                    parser.IsOperation = true;
                }
                parser.ReturnParameter.ReturnParameterSet(true);
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
        }