Ejemplo n.º 1
0
        public void SetState(string state)
        {
            var sr = new MyStringReader(state);

            SourceUri    = new Uri(sr.ReadLine());
            DestFilePath = sr.ReadLine();
            sr.ReadLine(); // skip Downloaded, which should be calculated from Ranges
            Length = long.Parse(sr.ReadLine());
            string line;

            while (!string.IsNullOrEmpty(line = sr.ReadLine()))
            {
                var splits = line.Split(seperator, 4);
                var range  = new Range {
                    Offset = long.Parse(splits[0]), Current = long.Parse(splits[1])
                };
                range.Length = long.Parse(splits[2]) - range.Offset + 1;
                Ranges.Add(range);
                Downloaded += range.Current;
            }
            if (Downloaded == Length)
            {
                State = DownloadState.Success;
            }
        }