public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) { ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context); if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterValue")) { return new InvalidParameterValueException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterCombination")) { return new InvalidParameterCombinationException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidCacheParameterGroupState")) { return new InvalidCacheParameterGroupStateException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("CacheParameterGroupNotFound")) { return new CacheParameterGroupNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } return new AmazonElastiCacheException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); }
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) { ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context); if (errorResponse.Code != null && errorResponse.Code.Equals("ListenerNotFound")) { return new ListenerNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("CertificateNotFound")) { return new CertificateNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("LoadBalancerNotFound")) { return new LoadBalancerNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidConfigurationRequest")) { return new InvalidConfigurationRequestException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } return new AmazonElasticLoadBalancingException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); }
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) { ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context); if (errorResponse.Code != null && errorResponse.Code.Equals("CacheSecurityGroupAlreadyExists")) { return new CacheSecurityGroupAlreadyExistsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterValue")) { return new InvalidParameterValueException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("QuotaExceeded.CacheSecurityGroup")) { return new CacheSecurityGroupQuotaExceededException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterCombination")) { return new InvalidParameterCombinationException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } return new AmazonElastiCacheException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); }
private static void UnmarshallResult(XmlUnmarshallerContext context, DetachLoadBalancerFromSubnetsResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("Subnets/member", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.Subnets.Add(item); continue; } } } return; }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { CreateConfigurationSetEventDestinationResponse response = new CreateConfigurationSetEventDestinationResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if(context.TestExpression("CreateConfigurationSetEventDestinationResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return response; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { DescribeInstanceStatusResponse response = new DescribeInstanceStatusResponse(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth = 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("instanceStatusSet/item", targetDepth)) { var unmarshaller = InstanceStatusUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.InstanceStatuses.Add(item); continue; } if (context.TestExpression("nextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = 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) { DetachLoadBalancerFromSubnetsResponse response = new DetachLoadBalancerFromSubnetsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if(context.TestExpression("DetachLoadBalancerFromSubnetsResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return response; }
private static void UnmarshallResult(XmlUnmarshallerContext context, ListSAMLProvidersResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("SAMLProviderList/member", targetDepth)) { var unmarshaller = SAMLProviderListEntryUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.SAMLProviderList.Add(item); continue; } } } return; }
private static void UnmarshallResult(XmlUnmarshallerContext context, ModifyDBParameterGroupResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("DBParameterGroupName", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.DBParameterGroupName = unmarshaller.Unmarshall(context); continue; } } } return; }
private static void UnmarshallResult(XmlUnmarshallerContext context,AttachLoadBalancerToSubnetsResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("Subnets/member", targetDepth)) { response.Subnets.Add(StringUnmarshaller.GetInstance().Unmarshall(context)); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { ModifyDBParameterGroupResponse response = new ModifyDBParameterGroupResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if(context.TestExpression("ModifyDBParameterGroupResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } 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) { AssociateVPCWithHostedZoneResponse response = new AssociateVPCWithHostedZoneResponse(); UnmarshallResult(context,response); return response; }
private static void UnmarshallResult(XmlUnmarshallerContext context, AssociateVPCWithHostedZoneResponse 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("ChangeInfo", targetDepth)) { var unmarshaller = ChangeInfoUnmarshaller.Instance; response.ChangeInfo = unmarshaller.Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { DescribeKeyPairsResponse response = new DescribeKeyPairsResponse(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth = 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("keySet/item", targetDepth)) { var unmarshaller = KeyPairInfoUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.KeyPairs.Add(item); continue; } } } return response; }
private static void UnmarshallResult(XmlUnmarshallerContext context, GetIdentityMailFromDomainAttributesResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("MailFromDomainAttributes/entry", targetDepth)) { var unmarshaller = new KeyValueUnmarshaller<string, IdentityMailFromDomainAttributes, StringUnmarshaller, IdentityMailFromDomainAttributesUnmarshaller>(StringUnmarshaller.Instance, IdentityMailFromDomainAttributesUnmarshaller.Instance); var item = unmarshaller.Unmarshall(context); response.MailFromDomainAttributes.Add(item); continue; } } } return; }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { GetIdentityMailFromDomainAttributesResponse response = new GetIdentityMailFromDomainAttributesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if(context.TestExpression("GetIdentityMailFromDomainAttributesResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return response; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { AuthorizeCacheSecurityGroupIngressResponse response = new AuthorizeCacheSecurityGroupIngressResponse(); while (context.Read()) { if (context.IsStartElement) { if(context.TestExpression("AuthorizeCacheSecurityGroupIngressResult", 2)) { UnmarshallResult(context,response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context); } } } return response; }
private static void UnmarshallResult(XmlUnmarshallerContext context,GetAccountSummaryResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("SummaryMap/entry", targetDepth)) { KeyValueUnmarshaller<string, int, StringUnmarshaller, IntUnmarshaller> unmarshaller = new KeyValueUnmarshaller<string, int, StringUnmarshaller, IntUnmarshaller>(StringUnmarshaller.GetInstance(), IntUnmarshaller.GetInstance()); KeyValuePair<string, int> kvp = unmarshaller.Unmarshall(context); response.SummaryMap.Add(kvp.Key, kvp.Value); 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(XmlUnmarshallerContext context) { ReplaceNetworkAclAssociationResponse response = new ReplaceNetworkAclAssociationResponse(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth = 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("newAssociationId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NewAssociationId = unmarshaller.Unmarshall(context); continue; } } } return response; }
private static void UnmarshallResult(XmlUnmarshallerContext context, GetRoleResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("Role", targetDepth)) { var unmarshaller = RoleUnmarshaller.Instance; response.Role = unmarshaller.Unmarshall(context); continue; } } } return; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { DescribeSnapshotAttributeResponse response = new DescribeSnapshotAttributeResponse(); int targetDepth = 2; while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("snapshotId", targetDepth)) { response.SnapshotId = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("createVolumePermission/item", targetDepth)) { response.CreateVolumePermissions.Add(CreateVolumePermissionUnmarshaller.GetInstance().Unmarshall(context)); continue; } if (context.TestExpression("productCodes/item", targetDepth)) { response.ProductCodes.Add(ProductCodeUnmarshaller.GetInstance().Unmarshall(context)); continue; } } } return response; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { CreateSpotDatafeedSubscriptionResponse response = new CreateSpotDatafeedSubscriptionResponse(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth = 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("spotDatafeedSubscription", targetDepth)) { var unmarshaller = SpotDatafeedSubscriptionUnmarshaller.Instance; response.SpotDatafeedSubscription = unmarshaller.Unmarshall(context); continue; } } } return response; }
private static void UnmarshallResult(XmlUnmarshallerContext context,DescribeApplicationsResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("Applications/member", targetDepth)) { response.Applications.Add(ApplicationDescriptionUnmarshaller.GetInstance().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(XmlUnmarshallerContext context) { AttachVpnGatewayResponse response = new AttachVpnGatewayResponse(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth = 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("attachment", targetDepth)) { var unmarshaller = VpcAttachmentUnmarshaller.Instance; response.VpcAttachment = unmarshaller.Unmarshall(context); continue; } } } return response; }
private static void UnmarshallResult(XmlUnmarshallerContext context, DescribeDBSecurityGroupsResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("DBSecurityGroups/DBSecurityGroup", targetDepth)) { var unmarshaller = DBSecurityGroupUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.DBSecurityGroups.Add(item); continue; } if (context.TestExpression("Marker", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Marker = unmarshaller.Unmarshall(context); continue; } } } return; }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { GetInvalidationResponse response = new GetInvalidationResponse(); UnmarshallResult(context,response); 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) { AddSourceIdentifierToSubscriptionResponse response = new AddSourceIdentifierToSubscriptionResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if(context.TestExpression("AddSourceIdentifierToSubscriptionResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return response; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { CreateCacheParameterGroupResponse response = new CreateCacheParameterGroupResponse(); while (context.Read()) { if (context.IsStartElement) { if(context.TestExpression("CreateCacheParameterGroupResult", 2)) { UnmarshallResult(context,response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context); } } } return response; }
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) { ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context); if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDenied")) { return new AccessDeniedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("BatchTooLarge")) { return new BatchTooLargeException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("InconsistentQuantities")) { return new InconsistentQuantitiesException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidArgument")) { return new InvalidArgumentException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("MissingBody")) { return new MissingBodyException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchDistribution")) { return new NoSuchDistributionException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyInvalidationsInProgress")) { return new TooManyInvalidationsInProgressException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); } return new AmazonCloudFrontException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode); }
private static void UnmarshallResult(XmlUnmarshallerContext context,GetBucketRequestPaymentResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("Payer", targetDepth)) { response.Payer = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }
public abstract AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext input);
public abstract AmazonServiceException UnmarshallException(XmlUnmarshallerContext input, Exception innerException, HttpStatusCode statusCode);
public virtual AmazonServiceException UnmarshallException(XmlUnmarshallerContext input, Exception innerException, HttpStatusCode statusCode) { throw new NotImplementedException(); }
public static T Unmarshall(XmlUnmarshallerContext context) { string text = context.ReadText(); return((T)Convert.ChangeType(text, typeof(T), CultureInfo.InvariantCulture)); }
Dictionary <TKey, TValue> IUnmarshaller <Dictionary <TKey, TValue>, XmlUnmarshallerContext> .Unmarshall(XmlUnmarshallerContext context) { throw new NotImplementedException(); }
/// <summary> /// Build an ErrorResponse from json /// </summary> /// <param name="context">The json parsing context. /// Usually an <c>Amazon.Runtime.Internal.JsonUnmarshallerContext</c>.</param> /// <returns>An <c>ErrorResponse</c> object.</returns> public ErrorResponse Unmarshall(JsonUnmarshallerContext context) { ErrorResponse response = new ErrorResponse(); if (context.Peek() == 60) //starts with '<' so assuming XML. { ErrorResponseUnmarshaller xmlUnmarshaller = new ErrorResponseUnmarshaller(); XmlUnmarshallerContext xmlContext = new XmlUnmarshallerContext(context.Stream, false, null); response = xmlUnmarshaller.Unmarshall(xmlContext); } else { while (context.Read()) { if (context.TestExpression("__type")) { string type = StringUnmarshaller.GetInstance().Unmarshall(context); response.Code = type.Substring(type.LastIndexOf("#", StringComparison.Ordinal) + 1); if (Enum.IsDefined(typeof(ErrorType), type)) { response.Type = (ErrorType)Enum.Parse(typeof(ErrorType), type, true); } else { response.Type = ErrorType.Unknown; } continue; } if (context.TestExpression("code")) { response.Code = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("message")) { response.Message = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } } // If an error code was not found, check for the x-amzn-ErrorType header. // This header is returned by rest-json services. if (string.IsNullOrEmpty(response.Code) && context.ResponseData.IsHeaderPresent(HeaderKeys.XAmzErrorType)) { var errorType = context.ResponseData.GetHeaderValue(HeaderKeys.XAmzErrorType); if (!string.IsNullOrEmpty(errorType)) { // The error type can contain additional information, with ":" as a delimiter // We are only interested in the initial part which is the error type var index = errorType.IndexOf(":", StringComparison.Ordinal); if (index != -1) { errorType = errorType.Substring(0, index); } response.Code = errorType; } } } return(response); }
/// <summary> /// Build an ErrorResponse from json /// </summary> /// <param name="context">The json parsing context. /// Usually an <c>Amazon.Runtime.Internal.JsonUnmarshallerContext</c>.</param> /// <returns>An <c>ErrorResponse</c> object.</returns> public ErrorResponse Unmarshall(JsonUnmarshallerContext context) { ErrorResponse response; if (context.Peek() == 60) //starts with '<' so assuming XML. { ErrorResponseUnmarshaller xmlUnmarshaller = new ErrorResponseUnmarshaller(); XmlUnmarshallerContext xmlContext = new XmlUnmarshallerContext(context.Stream, false, null); response = xmlUnmarshaller.Unmarshall(xmlContext); } else { string type = null; string message = null; string code = null; while (context.Read()) { if (context.TestExpression("__type")) { type = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("message")) { message = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("code")) { code = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } } // If an error code was not found, check for the x-amzn-ErrorType header. // This header is returned by rest-json services. if (string.IsNullOrEmpty(type) && context.ResponseData.IsHeaderPresent(HeaderKeys.XAmzErrorType)) { var errorType = context.ResponseData.GetHeaderValue(HeaderKeys.XAmzErrorType); if (!string.IsNullOrEmpty(errorType)) { // The error type can contain additional information, with ":" as a delimiter // We are only interested in the initial part which is the error type var index = errorType.IndexOf(":", StringComparison.Ordinal); if (index != -1) { errorType = errorType.Substring(0, index); } type = errorType; } } // Check for the x-amzn-error-message header. This header is returned by rest-json services. // If the header is present it is preferred over any value provided in the response body. if (context.ResponseData.IsHeaderPresent(HeaderKeys.XAmznErrorMessage)) { var errorMessage = context.ResponseData.GetHeaderValue(HeaderKeys.XAmznErrorMessage); if (!string.IsNullOrEmpty(errorMessage)) { message = errorMessage; } } // if both "__type" and HeaderKeys.XAmzErrorType were not specified, use "code" as type // this impacts Glacier if (string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(code)) { type = code; } // strip extra data from type, leaving only the exception type name type = type.Substring(type.LastIndexOf("#", StringComparison.Ordinal) + 1); response = new ErrorResponse { Code = type, Message = message, // type is not applicable to JSON services, setting to Unknown Type = ErrorType.Unknown }; } return(response); }
public virtual AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext input) { throw new NotImplementedException(); }
List <I> IUnmarshaller <List <I>, XmlUnmarshallerContext> .Unmarshall(XmlUnmarshallerContext context) { throw new NotImplementedException(); }