コード例 #1
0
        private static Func <string, object[]> GetOrCreateArgumentDeserializer(MethodOptions options)
        {
            var info                  = options.GetMethodOrThrow();
            var argsClass             = ArgumentList.GetArgumentClass(info.GetParameters().Select(p => p.ParameterType).ToArray());
            var deserializeMethod     = argsClass.GetMethod(nameof(ArgumentList.JsonDeserialize));
            var toParameterListMethod = argsClass.GetMethods(BindingFlags.Instance | BindingFlags.Public)
                                        .Where(m => string.Equals(nameof(ArgumentList.ToParameterList), m.Name))
                                        .Single();

            return(Deserialize);

            object[] Deserialize(string arguments)
            {
                var argsInstance = deserializeMethod.Invoke(null, new object[] { arguments });

                return((object[])toParameterListMethod.Invoke(argsInstance, Array.Empty <object>()));
            }
        }
コード例 #2
0
        private static Func <string, object> GetOrCreateInvoker(MethodOptions options, Func <string, object[]> argumentDeserializer)
        {
            var method = options.GetMethodOrThrow();

            return((string args) => method.Invoke(null, argumentDeserializer(args)));
        }