private void Awake() { Test = 10; string hotfixMonoBehaviourFullName = "HotFix_Project." + m_HotfixMonoBehaviourName; if (HotfixManager.Instance.ILRuntimeMode) { IType type = HotfixManager.Instance.Appdomain.LoadedTypes[hotfixMonoBehaviourFullName]; HotfixInstance = ((ILType)type).Instantiate(); m_Start = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Start", 0); m_Update = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Update", 0); m_Test = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Test", 1); HotfixManager.Instance.Appdomain.Invoke(hotfixMonoBehaviourFullName, "Awake", HotfixInstance, this); } else { HotfixInstance = HotfixManager.Instance.HotfixAssembly.CreateInstance(hotfixMonoBehaviourFullName); InstanceMethod awake = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Awake", new Type[] { typeof(MainMonoBehaviour) }); m_Start = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Start", null); m_Update = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Update", null); m_Test = new InstanceMethod(HotfixInstance, hotfixMonoBehaviourFullName, "Test", new Type[] { typeof(int) }); awake?.Invoke(this); } m_Test.Invoke(5); }
public void InvokeParameterlessMethodReturnsCorrectResult(object owner) { // Arrange var method = owner.GetType().GetMethod("GetHashCode", Type.EmptyTypes); var sut = new InstanceMethod(method, owner); // Act var result = sut.Invoke(Enumerable.Empty <object>()); // Assert var expected = owner.GetHashCode(); Assert.Equal(expected, result); }
public void InvokeMethodWithParametersReturnsCorrectResult(int x, int y) { // Arrange var owner = Comparer <int> .Default; var method = owner.GetType().GetMethod("Compare"); var sut = new InstanceMethod(method, owner); // Act var result = sut.Invoke(new object[] { x, y }); // Assert var expected = owner.Compare(x, y); Assert.Equal(expected, result); }
public void InvokeParameterlessMethodReturnsCorrectResult(object owner) { // Fixture setup var method = owner.GetType().GetMethod("GetHashCode", Type.EmptyTypes); var sut = new InstanceMethod(method, owner); // Exercise system var result = sut.Invoke(Enumerable.Empty <object>()); // Verify outcome var expected = owner.GetHashCode(); Assert.Equal(expected, result); // Teardown }
public void InvokeMethodWithParametersReturnsCorrectResult(int x, int y) { // Fixture setup var owner = Comparer <int> .Default; var method = owner.GetType().GetMethod("Compare"); var sut = new InstanceMethod(method, owner); // Exercise system var result = sut.Invoke(new object[] { x, y }); // Verify outcome var expected = owner.Compare(x, y); Assert.Equal(expected, result); // Teardown }
void Update() { m_Update?.Invoke(); }
void Start() { m_Start?.Invoke(); }
public void InvokeMethodWithParametersReturnsCorrectResult(int x, int y) { // Fixture setup var owner = Comparer<int>.Default; var method = owner.GetType().GetMethod("Compare"); var sut = new InstanceMethod(method, owner); // Exercise system var result = sut.Invoke(new object[] { x, y }); // Verify outcome var expected = owner.Compare(x, y); Assert.Equal(expected, result); // Teardown }
public void InvokeParameterlessMethodReturnsCorrectResult(object owner) { // Fixture setup var method = owner.GetType().GetMethod("GetHashCode"); var sut = new InstanceMethod(method, owner); // Exercise system var result = sut.Invoke(Enumerable.Empty<object>()); // Verify outcome var expected = owner.GetHashCode(); Assert.Equal(expected, result); // Teardown }