Esempio n. 1
0
        public static AlarmUnmarshaller GetInstance()
        {
            if (instance == null)
            {
                instance = new AlarmUnmarshaller();
            }

            return(instance);
        }
        public ScalingPolicy Unmarshall(UnmarshallerContext context)
        {
            ScalingPolicy scalingPolicy = new ScalingPolicy();
            int           originalDepth = context.CurrentDepth;
            int           targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

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

                        continue;
                    }
                    if (context.TestExpression("PolicyName", targetDepth))
                    {
                        scalingPolicy.PolicyName = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("ScalingAdjustment", targetDepth))
                    {
                        scalingPolicy.ScalingAdjustment = IntUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("AdjustmentType", targetDepth))
                    {
                        scalingPolicy.AdjustmentType = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("Cooldown", targetDepth))
                    {
                        scalingPolicy.Cooldown = IntUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("PolicyARN", targetDepth))
                    {
                        scalingPolicy.PolicyARN = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("Alarms/member", targetDepth))
                    {
                        scalingPolicy.Alarms.Add(AlarmUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return(scalingPolicy);
                }
            }

            return(scalingPolicy);
        }