Beispiel #1
0
        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);
        }
Beispiel #2
0
 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;
         }
     }
 }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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));
        }