예제 #1
0
파일: GpxReader.cs 프로젝트: zy6p/DEM.Net
        private GpxCopyright ReadGpxCopyright()
        {
            GpxCopyright copyright = new GpxCopyright();

            string elementName    = Reader_.Name;
            bool   isEmptyElement = Reader_.IsEmptyElement;

            while (Reader_.MoveToNextAttribute())
            {
                switch (Reader_.Name)
                {
                case "author":
                    copyright.Author = Reader_.Value;
                    break;
                }
            }

            if (isEmptyElement)
            {
                return(copyright);
            }

            while (Reader_.Read())
            {
                switch (Reader_.NodeType)
                {
                case XmlNodeType.Element:

                    switch (Reader_.Name)
                    {
                    case "year":
                        copyright.Year = ReadContentAsInt();
                        break;

                    case "license":
                        copyright.Licence = ReadContentAsString();
                        break;

                    default:
                        SkipElement();
                        break;
                    }

                    break;

                case XmlNodeType.EndElement:
                    if (Reader_.Name != elementName)
                    {
                        throw new FormatException(Reader_.Name);
                    }
                    return(copyright);
                }
            }

            throw new FormatException(elementName);
        }
예제 #2
0
파일: GpxWriter.cs 프로젝트: zy6p/DEM.Net
 private void WriteCopyright(string elementName, GpxCopyright copyright)
 {
     Writer_.WriteStartElement(elementName);
     Writer_.WriteAttributeString("author", copyright.Author);
     if (copyright.Year != null)
     {
         Writer_.WriteElementString("year", copyright.Year.Value.ToString());
     }
     if (copyright.Licence != null)
     {
         Writer_.WriteElementString("licence", copyright.Licence.ToString());
     }
     Writer_.WriteEndElement();
 }