public MethodInvocation Deserialize() { try { var type = System.Type.GetType(Type, throwOnError: false, ignoreCase: true); if (type == null) { throw new JobLoadException("Could not load the job."); } var parameterTypes = Helper.FromJson <Type[]>(ParameterTypes); var method = GetNonOpenMatchingMethod(type, Method, parameterTypes); if (method == null) { throw new JobLoadException(string.Format( "The type '{0}' does not contain a method with signature '{1}({2})'", type.FullName, Method, string.Join(", ", parameterTypes.Select(x => x.Name)))); } var serializedArguments = Helper.FromJson <string[]>(Arguments); var arguments = DeserializeArguments(method, serializedArguments); return(new MethodInvocation(type, method, arguments)); } catch (Exception ex) when(!(ex is JobLoadException)) { throw new JobLoadException("Could not load the job. See inner exception for the details.", ex); } }
private static object DeserializeArgument(string argument, Type type) { return(argument != null?Helper.FromJson(argument, type) : null); }