public static DimensionUnmarshaller GetInstance()
        {
            if (instance == null)
            {
                instance = new DimensionUnmarshaller();
            }

            return(instance);
        }
Пример #2
0
        public Metric Unmarshall(XmlUnmarshallerContext context)
        {
            Metric metric        = new Metric();
            int    originalDepth = context.CurrentDepth;
            int    targetDepth   = originalDepth + 1;

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

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

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

                        continue;
                    }
                    if (context.TestExpression("Dimensions/member", targetDepth))
                    {
                        metric.Dimensions.Add(DimensionUnmarshaller.GetInstance().Unmarshall(context));

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



            return(metric);
        }
Пример #3
0
        public MetricAlarm Unmarshall(XmlUnmarshallerContext context)
        {
            MetricAlarm metricAlarm   = new MetricAlarm();
            int         originalDepth = context.CurrentDepth;
            int         targetDepth   = originalDepth + 1;

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

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

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

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

                        continue;
                    }
                    if (context.TestExpression("AlarmConfigurationUpdatedTimestamp", targetDepth))
                    {
                        metricAlarm.AlarmConfigurationUpdatedTimestamp = DateTimeUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("ActionsEnabled", targetDepth))
                    {
                        metricAlarm.ActionsEnabled = BoolUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("OKActions/member", targetDepth))
                    {
                        metricAlarm.OKActions.Add(StringUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                    if (context.TestExpression("AlarmActions/member", targetDepth))
                    {
                        metricAlarm.AlarmActions.Add(StringUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                    if (context.TestExpression("InsufficientDataActions/member", targetDepth))
                    {
                        metricAlarm.InsufficientDataActions.Add(StringUnmarshaller.GetInstance().Unmarshall(context));

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

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

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

                        continue;
                    }
                    if (context.TestExpression("StateUpdatedTimestamp", targetDepth))
                    {
                        metricAlarm.StateUpdatedTimestamp = DateTimeUnmarshaller.GetInstance().Unmarshall(context);

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

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

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

                        continue;
                    }
                    if (context.TestExpression("Dimensions/member", targetDepth))
                    {
                        metricAlarm.Dimensions.Add(DimensionUnmarshaller.GetInstance().Unmarshall(context));

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

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

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

                        continue;
                    }
                    if (context.TestExpression("Threshold", targetDepth))
                    {
                        metricAlarm.Threshold = DoubleUnmarshaller.GetInstance().Unmarshall(context);

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

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



            return(metricAlarm);
        }