public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            AllocateAddressResponse response = new AllocateAddressResponse();

            int targetDepth = 2;

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("publicIp", targetDepth))
                    {
                        response.PublicIp = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("domain", targetDepth))
                    {
                        response.Domain = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("allocationId", targetDepth))
                    {
                        response.AllocationId = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                }
            }


            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            AllocateAddressResponse response = new AllocateAddressResponse();

            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("allocationId", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.AllocationId = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("domain", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.Domain = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("publicIp", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.PublicIp = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("publicIpv4Pool", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.PublicIpv4Pool = unmarshaller.Unmarshall(context);
                        continue;
                    }
                }
            }

            return(response);
        }
Ejemplo n.º 3
0
        internal string AllocateIp()
        {
            AllocateAddressResponse resp = ec2.AllocateAddress(new AllocateAddressRequest());

            return(resp.AllocateAddressResult.PublicIp);
        }