Пример #1
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetAttributesResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

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

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Attribute", targetDepth))
                    {
                        response.Attributes.Add(AttributeUnmarshaller.GetInstance().Unmarshall(context));

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



            return;
        }
Пример #2
0
        public static AttributeUnmarshaller GetInstance()
        {
            if (instance == null)
            {
                instance = new AttributeUnmarshaller();
            }

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

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

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

                        continue;
                    }
                    if (context.TestExpression("Name/@encoding", targetDepth))
                    {
                        item.AlternateNameEncoding = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("Attribute", targetDepth))
                    {
                        item.Attributes.Add(AttributeUnmarshaller.GetInstance().Unmarshall(context));

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



            return(item);
        }