/// <summary> /// Invokes generic method /// </summary> /// <param name="instance">Object to invoke generic method on</param> /// <param name="typeList">Generic parameter list</param> /// <param name="parameters">Method parameters</param> public object Invoke(object instance, GenericParameterList typeList, params object[] parameters) { if (!GenericMethodCache.ContainsKey(typeList)) { lock (GenericMethodCache) { if (!GenericMethodCache.ContainsKey(typeList)) { GenericMethodCache[typeList] = GenericMethod.MakeGenericMethod(typeList.Types); } } } var method = GenericMethodCache[typeList]; return method.FastInvoke(instance, parameters); }
/// <summary> /// Invokes generic method /// </summary> /// <param name="instance">Object to invoke generic method on</param> /// <param name="typeList">Generic parameter list</param> /// <param name="parameters">Method parameters</param> public object Invoke(object instance, GenericParameterList typeList, params object[] parameters) { if (!GenericMethodCache.ContainsKey(typeList)) { lock (GenericMethodCache) { if (!GenericMethodCache.ContainsKey(typeList)) { GenericMethodCache[typeList] = GenericMethod.MakeGenericMethod(typeList.Types); } } } var method = GenericMethodCache[typeList]; return(method.FastInvoke(instance, parameters)); }
/// <summary> /// Invokes generic method /// </summary> /// <param name="instance">Object to invoke generic method on</param> /// <param name="typeParameters">Generic parameters</param> /// <param name="parameters">Method parameters</param> public object Invoke(object instance, Type[] typeParameters, params object[] parameters) { var typeList = new GenericParameterList(typeParameters); return(Invoke(instance, typeList, parameters)); }
/// <summary> /// Invokes generic method /// </summary> /// <param name="instance">Object to invoke generic method on</param> /// <param name="typeParameters">Generic parameters</param> /// <param name="parameters">Method parameters</param> public object Invoke(object instance, Type[] typeParameters, params object[] parameters) { var typeList = new GenericParameterList(typeParameters); return Invoke(instance, typeList, parameters); }
public void NonEqualityTest() { var pl1 = new GenericParameterList(typeof(int), typeof(string)); var pl2 = new GenericParameterList(typeof(Dictionary<,>)); Assert.AreNotEqual(pl1, pl2); }
public void HashCodeTest() { var pl1 = new GenericParameterList(typeof(bool)); var pl2 = new GenericParameterList(typeof(bool)); Assert.AreEqual(pl1.GetHashCode(), pl2.GetHashCode()); }
public void EqualityTest() { var pl1 = new GenericParameterList(typeof(int), typeof(string)); var pl2 = new GenericParameterList(typeof(int), typeof(string)); Assert.AreEqual(pl1, pl2); }
public void CoverageRelatedTest() { var pl1 = new GenericParameterList(typeof(int), typeof(string)); var pl2 = new object(); Assert.AreNotEqual(pl1, pl2); }