예제 #1
0
        public static LoggingConfigUnmarshaller GetInstance()
        {
            if (instance == null)
            {
                instance = new LoggingConfigUnmarshaller();
            }

            return(instance);
        }
        public DistributionConfig Unmarshall(XmlUnmarshallerContext context)
        {
            DistributionConfig distributionConfig = new DistributionConfig();
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

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

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

                        continue;
                    }
                    if (context.TestExpression("Aliases", targetDepth))
                    {
                        distributionConfig.Aliases = AliasesUnmarshaller.GetInstance().Unmarshall(context);

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

                        continue;
                    }
                    if (context.TestExpression("Origins", targetDepth))
                    {
                        distributionConfig.Origins = OriginsUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("DefaultCacheBehavior", targetDepth))
                    {
                        distributionConfig.DefaultCacheBehavior = DefaultCacheBehaviorUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("CacheBehaviors", targetDepth))
                    {
                        distributionConfig.CacheBehaviors = CacheBehaviorsUnmarshaller.GetInstance().Unmarshall(context);

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

                        continue;
                    }
                    if (context.TestExpression("Logging", targetDepth))
                    {
                        distributionConfig.Logging = LoggingConfigUnmarshaller.GetInstance().Unmarshall(context);

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

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

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



            return(distributionConfig);
        }