public GetJobListResponse Parse(GetJobListRequest request, IWebResponse response) { using (response) { ResponseParseUtilities.HandleStatusCode(response, HttpStatusCode.OK); using (var stream = response.GetResponseStream()) { return(new GetJobListResponse( jobs: XmlExtensions .ReadDocument(stream) .ElementOrThrow("Jobs") .Elements("Job") .Select(jobElement => new JobInfo( jobElement.AttributeText("BucketName"), jobElement.AttributeText("StartDate"), Guid.Parse(jobElement.AttributeText("JobId")), jobElement.AttributeText("Priority"), jobElement.AttributeText("RequestType"), ResponseParseUtilities.ParseJobStatus(jobElement.AttributeText("Status")) )) .ToList() )); } } }
public static JobResponse ParseResponseContent(Stream content) { var masterObjectList = XmlExtensions.ReadDocument(content).ElementOrThrow("MasterObjectList"); return(new JobResponse( bucketName: masterObjectList.AttributeText("BucketName"), jobId: Guid.Parse(masterObjectList.AttributeText("JobId")), priority: masterObjectList.AttributeText("Priority"), requestType: masterObjectList.AttributeText("RequestType"), startDate: DateTime.Parse(masterObjectList.AttributeText("StartDate")), chunkOrder: ParseChunkOrdering(masterObjectList.AttributeText("ChunkClientProcessingOrderGuarantee")), nodes: ( from nodesElement in masterObjectList.Elements("Nodes") from nodeElement in nodesElement.Elements("Node") select new Node( Guid.Parse(nodeElement.AttributeText("Id")), nodeElement.AttributeText("EndPoint"), ParseIntOrNull(nodeElement.AttributeTextOrNull("HttpPort")), ParseIntOrNull(nodeElement.AttributeTextOrNull("HttpsPort")) ) ).ToList(), objectLists: masterObjectList .Elements("Objects") .Select(ParseObjectList) .ToList(), status: ResponseParseUtilities.ParseJobStatus(masterObjectList.AttributeTextOrNull("Status")) )); }