public JobInfo Deserialize(ReadOnlySpan <byte> data, string argsTag, IJobTypeProvider typeProvider) { var argsType = typeProvider.TagToType(argsTag); Tuple <Type, ToJobInfoDelegate> info; lock (SerializationInfo) { if (!SerializationInfo.TryGetValue(argsType, out info)) { var serializedType = typeof(SerializedEnvelope <>).MakeGenericType(argsType); // ReSharper disable once PossibleNullReferenceException var methodInfo = typeof(BaseSerializer).GetMethod(nameof(GetToJobInfoDelegate), BindingFlags.Static | BindingFlags.NonPublic) .MakeGenericMethod(argsType); var jobDelegate = (ToJobInfoDelegate)methodInfo.Invoke(null, new object[] { argsType }); info = new Tuple <Type, ToJobInfoDelegate>(serializedType, jobDelegate); SerializationInfo.Add(argsType, info); } } var serializedEnv = DeserializeEnvelope(data, info.Item1); return(info.Item2(serializedEnv, argsTag, typeProvider)); }
private static JobInfo ToJobInfo <T>(SerializedEnvelope <T> serialized, string argsTag, IJobTypeProvider typeProvider) { var argsType = typeProvider.TagToType(argsTag); var jobType = typeProvider.TagToType(serialized.J); return(new JobInfo { JobType = jobType, ArgsType = argsType, Args = serialized.A, Err = serialized.E, RunAtUtc = serialized.At, Retries = serialized.R, TimeoutMs = serialized.T, GroupKey = serialized.G, PeriodicRunInfo = serialized.P }); }