Esempio n. 1
0
        /// <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;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="parser">参数解析</param>
        internal override void QueryEnd(ref OperationParameter.NodeParser parser)
        {
            keyType key;

            switch (parser.OperationType)
            {
            case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(Dictionary.Count); return;

            case OperationParameter.OperationType.GetValue:
                if (HashCodeKey <keyType> .Get(ref parser, out key))
                {
                    valueType value;
                    if (Dictionary.TryGetValue(key, out value))
                    {
                        ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value);

                        parser.ReturnParameter.ReturnType = ReturnType.Success;
                    }
                    else
                    {
                        parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey;
                    }
                }
                return;

            case OperationParameter.OperationType.ContainsKey:
                if (HashCodeKey <keyType> .Get(ref parser, out key))
                {
                    parser.ReturnParameter.ReturnParameterSet(Dictionary.ContainsKey(key));
                }
                return;

            case OperationParameter.OperationType.GetValues:
                if (parser.OnReturn != null)
                {
                    if (parser.ValueData.Type == ValueData.DataType.ULong)
                    {
                        ulong count = parser.ValueData.Int64.ULong;
                        int   skipCount = (int)(uint)count, getCount = (int)(uint)(count >> 32);
                        if (skipCount >= 0 && getCount != 0)
                        {
                            parser.Cache.TcpServer.CallQueue.Add(new ServerCall.SearchTreeDictionaryGetter <keyType, valueType>(this, skipCount, getCount, ref parser));
                        }
                    }
                    parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
                }
                return;
            }
            parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError;
        }