Exemple #1
0
        public static DownloadService Load()
        {
            if (File.Exists(DnConf.StateFile) == false)
            {
                return(new DownloadService());
            }
            XmlSerializer formatter = new XmlSerializer(typeof(DownloadService));
            var           fs        = new FileStream(DnConf.StateFile, FileMode.Open);
            var           result    = (DownloadService)formatter.Deserialize(fs);

            fs.Close();
            foreach (var x in result.Tasks)
            {
                x.Transport = DnTransport.Make(x.FromUri);
                x.Name      = x.FromUri.Segments.Last();
                x.Segments.ForEach(y =>
                {
                    y.Parent    = x;
                    y.Transport = DnTransport.Make(x.FromUri);
                });
            }

            return(result);
        }
Exemple #2
0
 protected DnItem(CancellationToken token, Uri fromUri)
 {
     Token     = token;
     Transport = DnTransport.Make(fromUri);
 }