public static void CallBundleMethod(this IMvxViewModel viewModel, MethodInfo methodInfo, IMvxBundle bundle)
        {
            var parameters = methodInfo.GetParameters().ToArray();

            if (parameters.Count() == 1 &&
                parameters[0].ParameterType == typeof(IMvxBundle))
            {
                // this method is the 'normal' interface method
                methodInfo.Invoke(viewModel, new object[] { bundle });
                return;
            }

            if (parameters.Count() == 1 &&
                !MvxStringToTypeParser.TypeSupported(parameters[0].ParameterType))
            {
                // call method using typed object
                var value = bundle.Read(parameters[0].ParameterType);
                methodInfo.Invoke(viewModel, new[] { value });
                return;
            }

            // call method using named method arguments
            var invokeWith = bundle.CreateArgumentList(parameters, viewModel.GetType().Name)
                             .ToArray();

            methodInfo.Invoke(viewModel, invokeWith);
        }
 public void Test_AllTypesAreSupported()
 {
     Assert.IsTrue(MvxStringToTypeParser.TypeSupported(typeof(string)));
     Assert.IsTrue(MvxStringToTypeParser.TypeSupported(typeof(int)));
     Assert.IsTrue(MvxStringToTypeParser.TypeSupported(typeof(long)));
     Assert.IsTrue(MvxStringToTypeParser.TypeSupported(typeof(double)));
     Assert.IsTrue(MvxStringToTypeParser.TypeSupported(typeof(bool)));
     Assert.IsTrue(MvxStringToTypeParser.TypeSupported(typeof(Guid)));
     Assert.IsTrue(MvxStringToTypeParser.TypeSupported(typeof(StringSplitOptions)));
 }
        public void Test_AllTypesAreSupported()
        {
            var parser = new MvxStringToTypeParser();

            Assert.IsTrue(parser.TypeSupported(typeof(string)));
            Assert.IsTrue(parser.TypeSupported(typeof(int)));
            Assert.IsTrue(parser.TypeSupported(typeof(long)));
            Assert.IsTrue(parser.TypeSupported(typeof(short)));
            Assert.IsTrue(parser.TypeSupported(typeof(float)));
            Assert.IsTrue(parser.TypeSupported(typeof(uint)));
            Assert.IsTrue(parser.TypeSupported(typeof(ulong)));
            Assert.IsTrue(parser.TypeSupported(typeof(ushort)));
            Assert.IsTrue(parser.TypeSupported(typeof(double)));
            Assert.IsTrue(parser.TypeSupported(typeof(bool)));
            Assert.IsTrue(parser.TypeSupported(typeof(Guid)));
            Assert.IsTrue(parser.TypeSupported(typeof(StringSplitOptions)));
        }