Пример #1
0
 public static T GenericDeserialize <T>(this IWorkCommand <T> command, string str) where T : IWorkUnit
 {
     if (string.IsNullOrEmpty(str))
     {
         return(default(T));
     }
     return(JsonConvert.DeserializeObject <T>(str));
 }
Пример #2
0
        public static async Task <WorkResult <T> > RunAsync <T>(this IWorkCommand <T> command, string workblob, IProgress <IWorkProgress <T> > progress = null, CancellationToken token = default(CancellationToken)) where T : IWorkUnit
        {
            T workunit = await command.DeserializeAsync(workblob);

            if (workunit != null)
            {
                return(await command.RunAsync(workunit, progress, token));
            }
            return(new WorkResult <T>(WorkResultStatus.Error, "Unable to deserialize workblob"));
        }
Пример #3
0
 public static string GenericSerialize <T>(this IWorkCommand <T> command, T item) where T : IWorkUnit
 {
     return(JsonConvert.SerializeObject(item));
 }
Пример #4
0
 public static string Serialize <T>(this IWorkCommand <T> command, T workunit) where T : IWorkUnit
 {
     return(Task.Run(async() => await command.SerializeAsync(workunit)).Result);
 }
Пример #5
0
 public static T Deserialize <T>(this IWorkCommand <T> command, string str) where T : IWorkUnit
 {
     return(Task.Run(async() => await command.DeserializeAsync(str)).Result);
 }
Пример #6
0
 public static WorkResult <T> Run <T>(this IWorkCommand <T> command, string workblob, IProgress <IWorkProgress <T> > progress = null, CancellationToken token = default(CancellationToken)) where T : IWorkUnit
 {
     return(Task.Run(async() => await command.RunAsync(workblob, progress, token), token).Result);
 }