private static void UnmarshallResult(XmlUnmarshallerContext context, CreateListenerResponse 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("Listeners/member", targetDepth))
                    {
                        var unmarshaller = ListenerUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.Listeners.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)
        {
            CreateListenerResponse response = new CreateListenerResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("CreateListenerResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            CreateListenerRequest request;

            try
            {
                request = new CreateListenerRequest
                {
                    NetworkLoadBalancerId = NetworkLoadBalancerId,
                    CreateListenerDetails = CreateListenerDetails,
                    OpcRequestId = OpcRequestId,
                    OpcRetryToken = OpcRetryToken,
                    IfMatch = IfMatch
                };

                response = client.CreateListener(request).GetAwaiter().GetResult();
                WriteOutput(response, CreateWorkRequestObject(response.OpcWorkRequestId));
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateListenerResponse response = new CreateListenerResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Listener", targetDepth))
                {
                    var unmarshaller = ListenerUnmarshaller.Instance;
                    response.Listener = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }