private static double ReadValue(BinaryReader reader, BinaryDataType binaryDataType) { switch (binaryDataType) { case BinaryDataType.Float32: return(decimal.ToDouble(new decimal(reader.ReadSingle()))); case BinaryDataType.Float64: return(reader.ReadDouble()); case BinaryDataType.Int32: return((double)reader.ReadInt32()); case BinaryDataType.Int64: return((double)reader.ReadInt64()); default: throw new NotSupportedException("Data type not supported: " + binaryDataType.ToString()); } }
public static IParamContainer SetBinaryDataType( this IParamContainer pc, BinaryDataType binaryDataType) { switch (binaryDataType) { case BinaryDataType.Float32: return(pc.Set32BitFloat()); case BinaryDataType.Float64: return(pc.Set64BitFloat()); case BinaryDataType.Int32: return(pc.Set32BitInteger()); case BinaryDataType.Int64: return(pc.Set64BitInteger()); default: throw new NotSupportedException("Data type not supported: " + binaryDataType.ToString()); } }
private static void WriteValue(BinaryWriter writer, BinaryDataType binaryDataType, double value) { switch (binaryDataType) { case BinaryDataType.Float32: writer.Write((double)value); break; case BinaryDataType.Float64: writer.Write(value); break; case BinaryDataType.Int32: writer.Write((int)value); break; case BinaryDataType.Int64: writer.Write((long)value); break; default: throw new NotSupportedException("Data type not supported: " + binaryDataType.ToString()); } }