public override string Serialize() { string str = null; if (VideoLocal?.Hash != null) { InternalSerialize hf = new InternalSerialize { Hash = VideoLocal.Hash, ReadStates = ReadStates }; str = JsonConvert.SerializeObject(hf, JsonSettings); } return(str); }
public CmdAniDBAddFileToMyList(string str) { if (!string.IsNullOrEmpty(str)) { InternalSerialize hf = JsonConvert.DeserializeObject <InternalSerialize>(str, JsonSettings); SVR_VideoLocal vid = Repo.Instance.VideoLocal.GetByHash(hf.Hash); if (vid != null) { VideoLocal = vid; ReadStates = hf.ReadStates; } } }
public virtual async Task <string> SerializeAsync(HashFile workunit) { string str = null; if (workunit?.File != null) { InternalSerialize hf = new InternalSerialize { FileSystemName = workunit.File.FileSystem.Name, FullName = workunit.File.FullName, Type = workunit.Types, Force = workunit.Force }; str = JsonConvert.SerializeObject(hf); } //TODO add Logging on errors; return(await Task.FromResult(str)); }
public virtual async Task <HashFile> DeserializeAsync(string str) { HashFile ret = null; if (!string.IsNullOrEmpty(str)) { InternalSerialize hf = JsonConvert.DeserializeObject <InternalSerialize>(str); IFileSystem fs = Repo.Instance.ImportFolder.GetAll().FirstOrDefault(a => a.FileSystem.Name == hf.FileSystemName)?.FileSystem; if (fs != null) { IObject obj = await fs.ResolveAsync(hf.FullName); if (obj.Status == Status.Ok && obj is IFile file) { ret = new HashFile(file, hf.Type, hf.Force); } } } //TODO add Logging on errors; return(await Task.FromResult(ret)); }