Example #1
0
        public void GetFastMethodInvoker()
        {
            var instance = "stringContent";
            var invoker  = _cache.GetOrCreateFastMethodInvoker(
                instance.GetType(),
                "IsNullOrEmpty", new Type[0],
                new[] { typeof(string) },
                BindingFlags.Public | BindingFlags.Static);

            var output = invoker(null, new object[] { instance });

            Assert.That(output, Is.EqualTo(false));
        }
Example #2
0
        public static ReflectedObject CallMethod(Type type, string methodName, Type[] typeParameters, params object[] parameters)
        {
            ArgumentUtility.CheckNotNull("type", type);
            ArgumentUtility.CheckNotNull("methodName", methodName);
            ArgumentUtility.CheckNotNull("typeParameters", typeParameters);
            ArgumentUtility.CheckNotNull("parameters", parameters);

            var unwrappedParameters = UnWrapParameters(parameters);
            var argumentTypes       = unwrappedParameters.Select(obj => obj.GetType()).ToArray();
            var invoker             = s_cache.GetOrCreateFastMethodInvoker(type, methodName, typeParameters, argumentTypes, BindingFlags.Public | BindingFlags.Static);

            var returnValue = invoker(null, unwrappedParameters);

            return(returnValue == null ? null : new ReflectedObject(returnValue));
        }