public static int TestMethod(HFAStruct hfaStruct, IntStruct intStruct) { if (hfaStruct.f1 != 1.0f) { return(0); } if (hfaStruct.f2 != 2.0f) { return(1); } if (hfaStruct.f3 != 3.0f) { return(2); } if (intStruct.i1 != 1) { return(3); } if (intStruct.i2 != 2) { return(4); } if (intStruct.i3 != 3) { return(5); } return(100); }
} //Dispose() static byte[] Int2(uint i) { var num = new IntStruct(); num.Value = i; if (BitConverter.IsLittleEndian) { return new byte[] { num.B4, num.B3, num.B2, num.B1 } } ; else { return new byte[] { num.B1, num.B2, num.B3, num.B4 } }; }
/// <summary> /// write a int struct /// </summary> /// <param name="data"></param> public void Write(ref int data) { if (Length + 4 > _Buffer.Length) { _capacity += 4; Resize(); } var value = new IntStruct() { Value = data }; _Buffer[Length] = value.Byte0; _Buffer[Length + 1] = value.Byte1; _Buffer[Length + 2] = value.Byte2; _Buffer[Length + 3] = value.Byte3; Length += 4; }
public static int Main() { HFAStruct hfaStruct = new HFAStruct(); hfaStruct.f1 = 1.0f; hfaStruct.f2 = 2.0f; hfaStruct.f3 = 3.0f; IntStruct intStruct = new IntStruct(); intStruct.i1 = 1; intStruct.i2 = 2; intStruct.i3 = 3; int result = TestMethod(hfaStruct, intStruct); if (result != 100) { return(-result); } return((int)typeof(Test_hfaParam).GetMethod("TestMethod").Invoke(null, new object[] { hfaStruct, intStruct })); }
static void Set(ref IntStruct location, int value) { location.Value = value; }
static byte[] Int2(uint i) { var num = new IntStruct(); num.Value = i; if (BitConverter.IsLittleEndian) return new byte[] { num.B4, num.B3, num.B2, num.B1 }; else return new byte[] { num.B1, num.B2, num.B3, num.B4 }; }