private static void UnmarshallResult(XmlUnmarshallerContext context, GetObjectAttributesResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 1; } while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("Checksum", targetDepth)) { var unmarshaller = ChecksumUnmarshaller.Instance; response.Checksum = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("ETag", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ETag = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("ObjectParts", targetDepth)) { var unmarshaller = GetObjectAttributesPartsUnmarshaller.Instance; response.ObjectParts = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("ObjectSize", targetDepth)) { var unmarshaller = LongUnmarshaller.Instance; response.ObjectSize = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("StorageClass", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.StorageClass = unmarshaller.Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetObjectAttributesResponse response = new GetObjectAttributesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Attributes", targetDepth)) { var unmarshaller = new ListUnmarshaller <AttributeKeyAndValue, AttributeKeyAndValueUnmarshaller>(AttributeKeyAndValueUnmarshaller.Instance); response.Attributes = unmarshaller.Unmarshall(context); continue; } } return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { GetObjectAttributesResponse response = new GetObjectAttributesResponse(); UnmarshallResult(context, response); if (context.ResponseData.IsHeaderPresent("x-amz-delete-marker")) { if (context.ResponseData.IsHeaderPresent("Last-Modified")) { response.LastModified = DateTime.Parse(context.ResponseData.GetHeaderValue("Last-Modified"), CultureInfo.InvariantCulture); } } if (context.ResponseData.IsHeaderPresent("x-amz-request-charged")) { response.RequestCharged = context.ResponseData.GetHeaderValue("x-amz-request-charged"); } if (context.ResponseData.IsHeaderPresent("x-amz-version-id")) { response.VersionId = context.ResponseData.GetHeaderValue("x-amz-version-id"); } return(response); }