예제 #1
0
 private static XElement SerializeBucket(CrawlingBucket bucket)
 {
     return(new XElement("Bucket",
                         new XAttribute("Guid", bucket.Guid),
                         new XAttribute("Name", bucket.Name),
                         new XAttribute("Description", bucket.Description),
                         new XAttribute("NbThreads", bucket.NbThreads),
                         new XAttribute("NbRetry", bucket.NbRetry),
                         new XAttribute("LimitRequests", bucket.LimitRequests),
                         new XElement("HostMappings", bucket.HostMappings.Select(SerializeHostMapping))));
 }
예제 #2
0
        private static CrawlingBucket DeserializeBucket(XElement element)
        {
            CrawlingBucket bucket = new CrawlingBucket
            {
                Guid          = (Guid)element.Attribute("Guid"),
                Name          = (string)element.Attribute("Name"),
                Description   = (string)element.Attribute("Description"),
                NbThreads     = (int)element.Attribute("NbThreads"),
                NbRetry       = (int)element.Attribute("NbRetry"),
                LimitRequests = (int)element.Attribute("LimitRequests")
            };

            bucket.HostMappings.AddRange(element.Elements("HostMappings").Elements().Select(DeserializeHostMapping));

            return(bucket);
        }
예제 #3
0
 public static CrawlingBucket Clone(CrawlingBucket bucket)
 {
     return(DeserializeBucket(SerializeBucket(bucket)));
 }