Exemplo n.º 1
0
        public static PolicyAttributeDescriptionUnmarshaller GetInstance()
        {
            if (instance == null)
            {
                instance = new PolicyAttributeDescriptionUnmarshaller();
            }

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

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

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

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

                        continue;
                    }
                    if (context.TestExpression("PolicyAttributeDescriptions/member", targetDepth))
                    {
                        policyDescription.PolicyAttributeDescriptions.Add(PolicyAttributeDescriptionUnmarshaller.GetInstance().Unmarshall(context));

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



            return(policyDescription);
        }