Esempio n. 1
0
        private Parameter ReadParameter()
        {
            var parameter = new Parameter();

            parameter.Type = (ParameterType)reader.ReadInt32();

            switch (parameter.Type)
            {
            case ParameterType.Boolean:
                parameter.Value = reader.ReadBoolean();
                ReadNullBytes(9);
                break;

            case ParameterType.Integer:
                parameter.Value = reader.ReadInt32();
                ReadNullBytes(6);
                break;

            case ParameterType.Float:
            case ParameterType.Angle:
            case ParameterType.Percent:
                ReadNullBytes(4);
                parameter.Value = reader.ReadSingle();
                ReadNullBytes(2);
                break;

            case ParameterType.Location:
                parameter.Value = new float[]
                {
                    reader.ReadSingle(),
                        reader.ReadSingle(),
                        reader.ReadSingle()
                };
                break;

            case ParameterType.Color:
                parameter.Value = new byte[]
                {
                    reader.ReadByte(),     //B
                        reader.ReadByte(), //G
                        reader.ReadByte(), //R
                        reader.ReadByte()  //A
                };
                ReadNullBytes(6);
                break;

            case ParameterType.ComparisonOperator:
            case ParameterType.Surface:
            case ParameterType.ShakeIntensity:
            case ParameterType.Mood:
            case ParameterType.EvacuationSide:
            case ParameterType.RadarEvent:
            case ParameterType.Buildability:
            case ParameterType.Boundary:
                parameter.Value = EnumerationHelper.GetEnumerationValue((short)reader.ReadInt32(), parameter.Type);
                ReadNullBytes(6);
                break;

            case ParameterType.KindOf:
                parameter.Value = EnumerationHelper.GetEnumerationValue((short)reader.ReadInt32(), parameter.Type);
                ReadNullBytes(4);
                var kindOfAsString = ReadString();
                Assert(kindOfAsString == parameter.Value.ToString());
                break;

            default:
                ReadNullBytes(8);
                parameter.Value = ReadString();
                break;
            }
            Write(parameter.Type.ToString(), parameter.Value.ToString());
            return(parameter);
        }