public void Should_write_local_field_of_struct_via_field() { var func = CreateAction <StructHolder, string>(Expr.WriteField(Expr.ReadField(Expr.Parameter(0, typeof(StructHolder)), typeof(StructHolder).GetField("Struct")), _structLocal, Expr.Parameter(1, typeof(string)))); var holder = new StructHolder(); func(holder, "abc321"); Assert.That(holder.Struct.GetLocal(), Is.EqualTo("abc321")); }
public void ShouldSerializeStructMember() { object expected = new StructHolder { Date = new DateTime(2005, 05, 07), Int = 5, Int2 = null, Complex = new ComplexStruct { Text = "test", Span = new TimeSpan(1, 2, 3) } }; byte[] serialized = _serializer.Serialize(expected); var actual = _serializer.Deserialize <object>(serialized); Assert.That(actual, Is.EqualTo(expected)); }
void CheckSwitching() { float inventoryLength = 0; for (int i = 0; i < toolInventory.Length; i++) { if (toolInventory[i] != null) { inventoryLength += 1; } } if (Input.GetButtonDown(switchGunUpButton)) { if (equippedItem + 1 < inventoryLength) { if (toolInventory[equippedItem + 1] != null) { equippedItem += 1; } } else { equippedItem = 0; } } if (Input.GetButtonDown(switchGunDownButton)) { if (equippedItem - 1 >= 0) { if (toolInventory[equippedItem - 1] != null) { equippedItem -= 1; } } else { equippedItem = (int)inventoryLength - 1; } } gunn = gun.GetComponent <Destructible2D.D2dGun>(); currentWeapon = toolInventory[equippedItem].GetComponent <StructHolder>(); anim.runtimeAnimatorController = currentWeapon.weaponData.animationController; }