Exemple #1
0
        public override object parse(XmlNode objNode)
        {
            // get required poi's parameters
            string name      = objNode.SelectSingleNode("name").InnerText.Trim();
            double latitude  = Convert.ToDouble(objNode.SelectSingleNode("latitude").InnerText.Trim());
            double longitude = Convert.ToDouble(objNode.SelectSingleNode("longitude").InnerText.Trim());
            string lang      = objNode.SelectSingleNode("lang").InnerText.Trim();
            string type      = objNode.SelectSingleNode("type").InnerText.Trim();
            string descr     = objNode.SelectSingleNode("descr").InnerText.Trim();
            // instantiate poi
            Poi poi = new Poi(name, latitude, longitude, lang, type, descr);
            // parse media files

            MediaFilesXmlAdapter mediaFilesParser = new MediaFilesXmlAdapter(poi.getMediaFiles());
            XmlNode mediaFilesNode = objNode.SelectSingleNode(mediaFilesParser.getXmlNodeName());

            mediaFilesParser.parse(mediaFilesNode);

            MainDetailsXmlAdapter mainDetailsParser = new MainDetailsXmlAdapter(poi.getMainDetails());
            XmlNode mainDetailsNode = objNode.SelectSingleNode(mainDetailsParser.getXmlNodeName());

            mainDetailsParser.parse(mainDetailsNode);

            return(poi);
        }
Exemple #2
0
 public override string serialize(object obj)
 {
     MainDetail md = (MainDetail)obj;
     StringBuilder builder = new StringBuilder();
     // opening tag
     builder.Append("<");
     builder.Append(getXmlNodeName());
     builder.Append(">");
     // title
     builder.Append("<title>");
     builder.Append(md.getTitle());
     builder.Append("</title>");
     // description
     builder.Append("<descr><![CDATA[");
     builder.Append(md.getDescr());
     builder.Append("]]></descr>");
     // media files
     MediaFilesXmlAdapter mfxa = new MediaFilesXmlAdapter(md.getMediaFiles());
     string mediaFilesXml = mfxa.serialize();
     builder.Append(mediaFilesXml);
     // closing tag
     builder.Append("</");
     builder.Append(getXmlNodeName());
     builder.Append(">");
     return builder.ToString();
 }
Exemple #3
0
        public override string serialize(object obj)
        {
            MainDetail    md      = (MainDetail)obj;
            StringBuilder builder = new StringBuilder();

            // opening tag
            builder.Append("<");
            builder.Append(getXmlNodeName());
            builder.Append(">");
            // title
            builder.Append("<title>");
            builder.Append(md.getTitle());
            builder.Append("</title>");
            // description
            builder.Append("<descr><![CDATA[");
            builder.Append(md.getDescr());
            builder.Append("]]></descr>");
            // media files
            MediaFilesXmlAdapter mfxa = new MediaFilesXmlAdapter(md.getMediaFiles());
            string mediaFilesXml      = mfxa.serialize();

            builder.Append(mediaFilesXml);
            // closing tag
            builder.Append("</");
            builder.Append(getXmlNodeName());
            builder.Append(">");
            return(builder.ToString());
        }
Exemple #4
0
        public override object parse(XmlNode objNode)
        {
            string title = objNode.SelectSingleNode("title").InnerText.Trim();
            string descr = objNode.SelectSingleNode("descr").InnerText.Trim();
            MainDetail mainDetail = new MainDetail(title, descr);
            // parse media files
            MediaFilesXmlAdapter mediaFilesParser = new MediaFilesXmlAdapter(mainDetail.getMediaFiles());
            XmlNode mediaFilesNode = objNode.SelectSingleNode(mediaFilesParser.getXmlNodeName());
            mediaFilesParser.parse(mediaFilesNode);

            return mainDetail;
        }
Exemple #5
0
        public override object parse(XmlNode objNode)
        {
            string     title      = objNode.SelectSingleNode("title").InnerText.Trim();
            string     descr      = objNode.SelectSingleNode("descr").InnerText.Trim();
            MainDetail mainDetail = new MainDetail(title, descr);
            // parse media files
            MediaFilesXmlAdapter mediaFilesParser = new MediaFilesXmlAdapter(mainDetail.getMediaFiles());
            XmlNode mediaFilesNode = objNode.SelectSingleNode(mediaFilesParser.getXmlNodeName());

            mediaFilesParser.parse(mediaFilesNode);

            return(mainDetail);
        }
Exemple #6
0
        public override string serialize(object obj)
        {
            Poi           p       = (Poi)obj;
            StringBuilder builder = new StringBuilder();

            // opening tag
            builder.Append("<");
            builder.Append(getXmlNodeName());
            builder.Append(">");
            // lang
            builder.Append("<lang>");
            builder.Append(p.getLang());
            builder.Append("</lang>");
            // name
            builder.Append("<name>");
            builder.Append(p.getName());
            builder.Append("</name>");
            // latitude
            builder.Append("<latitude>");
            builder.Append(p.getLatitude());
            builder.Append("</latitude>");
            // longitude
            builder.Append("<longitude>");
            builder.Append(p.getLongitude());
            builder.Append("</longitude>");
            // type
            builder.Append("<type>");
            builder.Append(p.getType());
            builder.Append("</type>");
            // description
            builder.Append("<descr><![CDATA[");
            builder.Append(p.getDescr());
            builder.Append("]]></descr>");
            // media files
            MediaFilesXmlAdapter mfxa = new MediaFilesXmlAdapter(p.getMediaFiles());
            string mediaFilesXml      = mfxa.serialize();

            builder.Append(mediaFilesXml);
            // main details
            MainDetailsXmlAdapter mdxa = new MainDetailsXmlAdapter(p.getMainDetails());
            string mainDetailsXml      = mdxa.serialize();

            builder.Append(mainDetailsXml);
            // closing tag
            builder.Append("</");
            builder.Append(getXmlNodeName());
            builder.Append(">");
            return(builder.ToString());
        }
Exemple #7
0
 public override string serialize(object obj)
 {
     Poi p = (Poi)obj;
     StringBuilder builder = new StringBuilder();
     // opening tag
     builder.Append("<");
     builder.Append(getXmlNodeName());
     builder.Append(">");
     // lang
     builder.Append("<lang>");
     builder.Append(p.getLang());
     builder.Append("</lang>");
     // name
     builder.Append("<name>");
     builder.Append(p.getName());
     builder.Append("</name>");
     // latitude
     builder.Append("<latitude>");
     builder.Append(p.getLatitude());
     builder.Append("</latitude>");
     // longitude
     builder.Append("<longitude>");
     builder.Append(p.getLongitude());
     builder.Append("</longitude>");
     // type
     builder.Append("<type>");
     builder.Append(p.getType());
     builder.Append("</type>");
     // description
     builder.Append("<descr><![CDATA[");
     builder.Append(p.getDescr());
     builder.Append("]]></descr>");
     // media files
     MediaFilesXmlAdapter mfxa = new MediaFilesXmlAdapter(p.getMediaFiles());
     string mediaFilesXml = mfxa.serialize();
     builder.Append(mediaFilesXml);
     // main details
     MainDetailsXmlAdapter mdxa = new MainDetailsXmlAdapter(p.getMainDetails());
     string mainDetailsXml = mdxa.serialize();
     builder.Append(mainDetailsXml);
     // closing tag
     builder.Append("</");
     builder.Append(getXmlNodeName());
     builder.Append(">");
     return builder.ToString();
 }
Exemple #8
0
        public override object parse(XmlNode objNode)
        {
            // get required poi's parameters
            string name = objNode.SelectSingleNode("name").InnerText.Trim();
            double latitude = Convert.ToDouble(objNode.SelectSingleNode("latitude").InnerText.Trim());
            double longitude = Convert.ToDouble(objNode.SelectSingleNode("longitude").InnerText.Trim());
            string lang = objNode.SelectSingleNode("lang").InnerText.Trim();
            string type = objNode.SelectSingleNode("type").InnerText.Trim();
            string descr = objNode.SelectSingleNode("descr").InnerText.Trim();
            // instantiate poi
            Poi poi = new Poi(name, latitude, longitude, lang, type, descr);
            // parse media files

            MediaFilesXmlAdapter mediaFilesParser = new MediaFilesXmlAdapter(poi.getMediaFiles());
            XmlNode mediaFilesNode = objNode.SelectSingleNode(mediaFilesParser.getXmlNodeName());
            mediaFilesParser.parse(mediaFilesNode);

            MainDetailsXmlAdapter mainDetailsParser = new MainDetailsXmlAdapter(poi.getMainDetails());
            XmlNode mainDetailsNode = objNode.SelectSingleNode(mainDetailsParser.getXmlNodeName());
            mainDetailsParser.parse(mainDetailsNode);

            return poi;
        }
Exemple #9
0
 /**
  * Loads Poi media data: media files and main details.
  */
 public void loadMedia(Poi poi, string poiSubDir)
 {
     //Debug.WriteLine("loadMedia: poi sub dir: " + poiSubDir, ToString());
     // load xml document
     XmlDocument poiXmlDoc = new XmlDocument();
     string poiXmlPath = getPoiXmlPath(poiSubDir);
     poiXmlDoc.Load(poiXmlPath);
     // get media files
     XmlNode mediaFilesNode = poiXmlDoc.SelectSingleNode("/poi/media_files");
     if (mediaFilesNode != null)
     {
         MediaFilesXmlAdapter mfxa = new MediaFilesXmlAdapter(poi.getMediaFiles());
         mfxa.parse(mediaFilesNode);
     }
     // get main details
     XmlNode mainDetailsNode = poiXmlDoc.SelectSingleNode("/poi/details");
     if (mainDetailsNode != null)
     {
         MainDetailsXmlAdapter mdxa = new MainDetailsXmlAdapter(poi.getMainDetails());
         mdxa.parse(mainDetailsNode);
     }
     string poiMediaFilesPath = getPoiMediaFilesPath(poiSubDir);
     if (poiMediaFilesPath != null)
     {
         loadMediaFiles(poi.getAllMediaFiles(), poiMediaFilesPath);
     }
 }