예제 #1
0
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="parser"></param>
        private unsafe void update(ref OperationParameter.NodeParser parser)
        {
            int index = parser.GetValueData(-1);

            if ((uint)index < count)
            {
                byte *read = parser.Read;
                if (parser.LoadValueData() && !parser.IsEnd)
                {
                    valueType updateValue = ValueData.Data <valueType> .GetData(ref parser.ValueData);

                    if (parser.LoadValueData() && parser.ValueData.Type == ValueData.DataType.UInt)
                    {
                        valueType[] array = arrays[index >> FragmentArray.ArrayShift];
                        valueType   value = array[index &= FragmentArray.ArraySizeAnd];
                        uint        type  = parser.ValueData.Int64.UInt;
                        OperationUpdater.LogicType logicType = (OperationUpdater.LogicType)(byte)(type >> 16);
                        if (logicType != OperationUpdater.LogicType.None && parser.LoadValueData() && parser.IsEnd)
                        {
                            if (OperationUpdater.Data <valueType> .IsLogicData(logicType, value, ValueData.Data <valueType> .GetData(ref parser.ValueData)))
                            {
                                logicType = OperationUpdater.LogicType.None;
                            }
                            else
                            {
                                parser.ReturnParameter.ReturnType = ReturnType.Success;
                                ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value);

                                return;
                            }
                        }
                        if (logicType == OperationUpdater.LogicType.None && parser.IsEnd)
                        {
                            switch (parser.ReturnParameter.ReturnType = OperationUpdater.Data <valueType> .UpdateData((OperationUpdater.OperationType)(ushort) type, ref value, updateValue))
                            {
                            case ReturnType.Success:
                                array[index] = value;
                                parser.UpdateOperation(read, value, OperationParameter.OperationType.SetValue);
                                goto SETDATA;

                            case ReturnType.Unknown:
                                parser.ReturnParameter.ReturnType = ReturnType.Success;
SETDATA:
                                ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value);

                                return;
                            }
                            return;
                        }
                    }
                }
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ArrayIndexOutOfRange;
            }
        }
예제 #2
0
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="parser"></param>
        private unsafe void update(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                valueType value;
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, valueType> dictionary;
                if (fragmentDictionary.TryGetValue(key, out value, out dictionary))
                {
                    byte *read = parser.Read;
                    if (parser.LoadValueData() && !parser.IsEnd)
                    {
                        valueType updateValue = ValueData.Data <valueType> .GetData(ref parser.ValueData);

                        if (parser.LoadValueData() && parser.ValueData.Type == ValueData.DataType.UInt)
                        {
                            uint type = parser.ValueData.Int64.UInt;
                            OperationUpdater.LogicType logicType = (OperationUpdater.LogicType)(byte)(type >> 16);
                            if (logicType != OperationUpdater.LogicType.None && parser.LoadValueData() && parser.IsEnd)
                            {
                                if (OperationUpdater.Data <valueType> .IsLogicData(logicType, value, ValueData.Data <valueType> .GetData(ref parser.ValueData)))
                                {
                                    logicType = OperationUpdater.LogicType.None;
                                }
                                else
                                {
                                    parser.ReturnParameter.ReturnType = ReturnType.Success;
                                    ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value);

                                    return;
                                }
                            }
                            if (logicType == OperationUpdater.LogicType.None && parser.IsEnd)
                            {
                                switch (parser.ReturnParameter.ReturnType = OperationUpdater.Data <valueType> .UpdateData((OperationUpdater.OperationType)(ushort) type, ref value, updateValue))
                                {
                                case ReturnType.Success:
                                    dictionary[key] = value;
                                    parser.UpdateOperation(read, value, OperationParameter.OperationType.SetValue);
                                    goto SETDATA;

                                case ReturnType.Unknown:
                                    parser.ReturnParameter.ReturnType = ReturnType.Success;
SETDATA:
                                    ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value);

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