/// <summary>
        /// Deserializes the object from XML.
        /// </summary>
        /// <param name="reader">The xml reader from which to deserialize the object.</param>
        public void ReadXml(XmlReader reader)
        {
            bool booIsEmpty = reader.IsEmptyElement;

            if (booIsEmpty)
            {
                return;
            }
            reader.ReadStartElement();

            reader.ReadStartElement("sourceUri");
            XmlSerializer xsrSerializer = new XmlSerializer(typeof(string));

            SourceUri = new Uri((string)xsrSerializer.Deserialize(reader));
            reader.ReadEndElement();

            reader.ReadStartElement("sourcePath");
            xsrSerializer = new XmlSerializer(typeof(string));
            SourcePath    = (string)xsrSerializer.Deserialize(reader);
            reader.ReadEndElement();

            booIsEmpty = reader.IsEmptyElement;
            try
            {
                reader.ReadStartElement("sourceName");

                if (!booIsEmpty)
                {
                    while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "string")
                    {
                        xsrSerializer = new XmlSerializer(typeof(string));
                        SourceName.Add((string)xsrSerializer.Deserialize(reader));
                    }
                    reader.ReadEndElement();
                }
            }
            catch
            {
            }
            finally
            {
                if (SourceName.Count == 0)
                {
                    SourceName.Add("Default");
                }
            }

            reader.ReadStartElement("defaultSourcePath");
            xsrSerializer     = new XmlSerializer(typeof(string));
            DefaultSourcePath = (string)xsrSerializer.Deserialize(reader);
            reader.ReadEndElement();


            try
            {
                reader.ReadStartElement("status");
                xsrSerializer = new XmlSerializer(typeof(TaskStatus));
                Status        = (TaskStatus)xsrSerializer.Deserialize(reader);
                reader.ReadEndElement();
            }
            catch
            {
                Status = TaskStatus.Paused;
            }

            booIsEmpty = reader.IsEmptyElement;
            reader.ReadStartElement("downloadFiles");
            if (!booIsEmpty)
            {
                while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "file")
                {
                    DownloadFiles.Add(new Uri(reader["path"]));
                    booIsEmpty = reader.IsEmptyElement;
                    reader.ReadStartElement("file");
                    if (!booIsEmpty)
                    {
                        reader.ReadEndElement();
                    }
                }
                reader.ReadEndElement();
            }

            booIsEmpty = reader.IsEmptyElement;
            reader.ReadStartElement("downloadedFiles");
            if (!booIsEmpty)
            {
                while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "file")
                {
                    DownloadedFiles.Add(reader["path"]);
                    booIsEmpty = reader.IsEmptyElement;
                    reader.ReadStartElement("file");
                    if (!booIsEmpty)
                    {
                        reader.ReadEndElement();
                    }
                }
                reader.ReadEndElement();
            }

            reader.ReadEndElement();
        }
 public void DownloadFile(string resource, string saveAs)
 {
     DownloadedFiles.Add(new DownloadedFile(resource, saveAs, Cookies));
 }