예제 #1
0
        internal static AllplanAttributeSet ReadFrom(XmlReader reader)
        {
            if (reader.NodeType != XmlNodeType.Element)
            {
                throw new NotSupportedException($"Expecting element type");
            }
            if (!reader.Name.Equals(ELEMENT_NAME))
            {
                throw new NotSupportedException($"Expecting '{ELEMENT_NAME}' as prefix. Got '{reader.Name}'");
            }

            var attribSet = new AllplanAttributeSet
            {
                Key = reader.GetAttribute("KEY")
            };

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.Name.StartsWith(AllplanAttribute.ELEMENT_NAME))
                    {
                        attribSet.Attributes.Add(AllplanAttribute.ReadFrom(reader));
                    }
                    else
                    {
                        throw new NotImplementedException($"Missing implementation for element '{reader.Name}'");
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (reader.Name.Equals(ELEMENT_NAME))
                    {
                        return(attribSet);
                    }
                    break;
                }
            }

            throw new NotSupportedException($"Unexpected end of file");
        }
예제 #2
0
        internal static AllplanAttributesContainer ReadFrom(XmlReader reader)
        {
            if (reader.NodeType != XmlNodeType.Element)
            {
                throw new NotSupportedException($"Expecting element type");
            }
            if (!reader.Name.Equals(ELEMENT_NAME))
            {
                throw new NotSupportedException($"Expecting '{ELEMENT_NAME}' as prefix. Got '{reader.Name}'");
            }

            var container = new AllplanAttributesContainer
            {
                Version  = reader.GetAttribute("VERSION"),
                FileType = reader.GetAttribute("FILETYPE")
            };

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.Name.Equals(AllplanAttributeSet.ELEMENT_NAME))
                    {
                        container.AttributeSet = AllplanAttributeSet.ReadFrom(reader);
                    }
                    else
                    {
                        throw new NotImplementedException($"Missing implementation for element '{reader.Name}'");
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (reader.Name.Equals(ELEMENT_NAME))
                    {
                        return(container);
                    }
                    break;
                }
            }
            throw new NotSupportedException($"Unexpected end of file");
        }