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)))); }
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); }
public static CrawlingBucket Clone(CrawlingBucket bucket) { return(DeserializeBucket(SerializeBucket(bucket))); }