Esempio n. 1
0
 public bool Has(string key)
 {
     return(DoubleValues.ContainsKey(key));
 }
Esempio n. 2
0
        public ExecutionState LoadData(ByteReader br)
        {
            while (br.Avaliable > 0)
            {
                var Name = br.ReadString();
                if (!Name)
                {
                    return(ExecutionState.Failed());
                }
                var Type = br.ReadByte();
                if (!Type)
                {
                    return(ExecutionState.Failed());
                }
                if (!DataTypeHelper.TryParse(Type.Result, out DataType TypeResult))
                {
                    return(ExecutionState.Failed());
                }
                switch (TypeResult)
                {
                case DataType.type_byte:
                    var ValueByte = br.ReadByte();
                    if (!ValueByte)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (ByteValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    ByteValues.Add(Name.Result, ValueByte.Result);
                    break;

                case DataType.type_sbyte:
                    var ValueSByte = br.ReadSByte();
                    if (!ValueSByte)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (SByteValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    SByteValues.Add(Name.Result, ValueSByte.Result);
                    break;

                case DataType.type_short:
                    var ValueShort = br.ReadShort();
                    if (!ValueShort)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (ShortValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    ShortValues.Add(Name.Result, ValueShort.Result);
                    break;

                case DataType.type_ushort:
                    var ValueUShort = br.ReadUShort();
                    if (!ValueUShort)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (UShortValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    UShortValues.Add(Name.Result, ValueUShort.Result);
                    break;

                case DataType.type_int:
                    var ValueInt = br.ReadInt();
                    if (!ValueInt)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (IntValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    IntValues.Add(Name.Result, ValueInt.Result);
                    break;

                case DataType.type_uint:
                    var ValueUInt = br.ReadUInt();
                    if (!ValueUInt)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (UIntValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    UIntValues.Add(Name.Result, ValueUInt.Result);
                    break;

                case DataType.type_long:
                    var ValueLong = br.ReadLong();
                    if (!ValueLong)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (LongValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    LongValues.Add(Name.Result, ValueLong.Result);
                    break;

                case DataType.type_ulong:
                    var ValueULong = br.ReadULong();
                    if (!ValueULong)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (ULongValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    ULongValues.Add(Name.Result, ValueULong.Result);
                    break;

                case DataType.type_single:
                    var ValueSingle = br.ReadSingle();
                    if (!ValueSingle)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (SingleValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    SingleValues.Add(Name.Result, ValueSingle.Result);
                    break;

                case DataType.type_double:
                    var ValueDobule = br.ReadDouble();
                    if (!ValueDobule)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (DoubleValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    DoubleValues.Add(Name.Result, ValueDobule.Result);
                    break;

                case DataType.type_string:
                    var ValueString = br.ReadString();
                    if (!ValueString)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (StringValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    StringValues.Add(Name.Result, ValueString.Result);
                    break;
                }
            }

            return(ExecutionState.Succeeded());
        }