internal void WriteValue(BinaryWriterEx bw, object value) { switch (Type) { case ParamType.aob: bw.WriteBytes((byte[])value); break; case ParamType.b: bw.WriteBoolean((bool)value); break; case ParamType.u8: case ParamType.x8: bw.WriteByte((byte)value); break; case ParamType.s8: bw.WriteSByte((sbyte)value); break; case ParamType.u16: case ParamType.x16: bw.WriteUInt16((ushort)value); break; case ParamType.s16: bw.WriteInt16((short)value); break; case ParamType.u32: case ParamType.x32: bw.WriteUInt32((uint)value); break; case ParamType.s32: bw.WriteInt32((int)value); break; case ParamType.u64: case ParamType.x64: bw.WriteUInt64((ulong)value); break; case ParamType.s64: bw.WriteInt64((long)value); break; case ParamType.f32: bw.WriteSingle((float)value); break; case ParamType.f64: bw.WriteDouble((double)value); break; default: throw new Exception($"Invalid ParamTemplate ParamType: {Type.ToString()}"); } }
internal void WriteValue(BinaryWriterEx bw, object value) { switch (Type) { case ParamType.aob: bw.WriteBytes((byte[])value); break; case ParamType.b: bw.WriteBoolean((bool)value); break; case ParamType.u8: case ParamType.x8: bw.WriteByte(Convert.ToByte(value)); break; case ParamType.s8: bw.WriteSByte(Convert.ToSByte(value)); break; case ParamType.u16: case ParamType.x16: bw.WriteUInt16(Convert.ToUInt16(value)); break; case ParamType.s16: bw.WriteInt16(Convert.ToInt16(value)); break; case ParamType.u32: case ParamType.x32: bw.WriteUInt32(Convert.ToUInt32(value)); break; case ParamType.s32: bw.WriteInt32(Convert.ToInt32(value)); break; case ParamType.u64: case ParamType.x64: bw.WriteUInt64(Convert.ToUInt64(value)); break; case ParamType.s64: bw.WriteInt64(Convert.ToInt64(value)); break; case ParamType.f32: bw.WriteSingle(Convert.ToSingle(value)); break; case ParamType.f64: bw.WriteDouble(Convert.ToDouble(value)); break; default: throw new Exception($"Invalid ParamTemplate ParamType: {Type.ToString()}"); } }
internal void WriteDefaultValue(BinaryWriterEx bw) { if (ValueToAssert != null) { WriteAssertValue(bw); } else if (DefaultValue == null) { switch (Type) { case ParamType.aob: for (int i = 0; i < AobLength; i++) { bw.WriteByte(0); } break; case ParamType.b: case ParamType.u8: case ParamType.x8: bw.WriteByte(0); break; case ParamType.s8: bw.WriteSByte(0); break; case ParamType.u16: case ParamType.x16: bw.WriteUInt16(0); break; case ParamType.s16: bw.WriteInt16(0); break; case ParamType.u32: case ParamType.x32: bw.WriteUInt32(0); break; case ParamType.s32: bw.WriteInt32(0); break; case ParamType.u64: case ParamType.x64: bw.WriteUInt64(0); break; case ParamType.s64: bw.WriteInt64(0); break; case ParamType.f32: bw.WriteSingle(0); break; case ParamType.f64: bw.WriteDouble(0); break; default: throw new Exception($"Invalid ParamTemplate ParamType: {Type.ToString()}"); } } else { switch (Type) { case ParamType.aob: var assertAob = (byte[])DefaultValue; bw.WriteBytes(assertAob); break; case ParamType.b: case ParamType.u8: case ParamType.x8: bw.WriteByte((byte)DefaultValue); break; case ParamType.s8: bw.WriteSByte((sbyte)DefaultValue); break; case ParamType.u16: case ParamType.x16: bw.WriteUInt16((ushort)DefaultValue); break; case ParamType.s16: bw.WriteInt16((short)DefaultValue); break; case ParamType.u32: case ParamType.x32: bw.WriteUInt32((uint)DefaultValue); break; case ParamType.s32: bw.WriteInt32((int)DefaultValue); break; case ParamType.u64: case ParamType.x64: bw.WriteUInt64((ulong)DefaultValue); break; case ParamType.s64: bw.WriteInt64((long)DefaultValue); break; case ParamType.f32: bw.WriteSingle((float)DefaultValue); break; case ParamType.f64: bw.WriteDouble((double)DefaultValue); break; default: throw new Exception($"Invalid ParamTemplate ParamType: {Type.ToString()}"); } } }