Exemplo n.º 1
0
        /// <summary>
        /// Gets WTML details.
        /// </summary>
        /// <param name="filePath">File Path.</param>
        /// <returns>WTML collection from the xml.</returns>
        private static WTMLCollection GetWtmlDetails(string filePath)
        {
            WTMLCollection wtmlDetails = null;
            XmlDocument    xmlDoc      = new XmlDocument();

            try
            {
                xmlDoc.Load(filePath);
                XmlNode imageSet = xmlDoc.SelectSingleNode(Constants.ImageSetPath);
                if (imageSet != null)
                {
                    wtmlDetails = new WTMLCollection();
                    if (imageSet.Attributes[Constants.WTMLElevationModelAttribute] != null)
                    {
                        bool elevationModel;
                        if (bool.TryParse(imageSet.Attributes[Constants.WTMLElevationModelAttribute].Value, out elevationModel))
                        {
                            wtmlDetails.IsElevationModel = elevationModel;
                        }
                    }
                    if (imageSet.Attributes[Constants.WTMLName] != null)
                    {
                        wtmlDetails.Name = imageSet.Attributes[Constants.WTMLName].Value;
                    }
                    if (imageSet.Attributes[Constants.WTMLTileLevel] != null)
                    {
                        wtmlDetails.Levels = imageSet.Attributes[Constants.WTMLTileLevel].Value;
                    }
                    if (imageSet.Attributes[Constants.WTMLProjection] != null)
                    {
                        wtmlDetails.ProjectType = imageSet.Attributes[Constants.WTMLProjection].Value;
                    }
                    if (imageSet.Attributes[Constants.DEMUrl] != null)
                    {
                        wtmlDetails.IsDemEnabled = true;
                    }
                    if (imageSet.SelectSingleNode(Constants.Credits) != null)
                    {
                        wtmlDetails.Credit = imageSet.SelectSingleNode(Constants.Credits).InnerText;
                    }
                    if (imageSet.SelectSingleNode(Constants.CreditURL) != null)
                    {
                        wtmlDetails.CreditPath = imageSet.SelectSingleNode(Constants.CreditURL).InnerText;
                    }
                }
            }
            catch (XmlException ex)
            {
                ErrorHandler.LogException(ex);
                throw new FaultException(ex.Message);
            }
            catch (IOException ex)
            {
                ErrorHandler.LogException(ex);
                throw new FaultException(ex.Message);
            }
            catch (SecurityException ex)
            {
                ErrorHandler.LogException(ex);
                throw new FaultException(ex.Message);
            }
            return(wtmlDetails);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets WTML details.
 /// </summary>
 /// <param name="filePath">File Path.</param>
 /// <returns>WTML collection from the xml.</returns>
 private static WTMLCollection GetWtmlDetails(string filePath)
 {
     WTMLCollection wtmlDetails = null;
     XmlDocument xmlDoc = new XmlDocument();
     try
     {
         xmlDoc.Load(filePath);
         XmlNode imageSet = xmlDoc.SelectSingleNode(Constants.ImageSetPath);
         if (imageSet != null)
         {
             wtmlDetails = new WTMLCollection();
             if (imageSet.Attributes[Constants.WTMLElevationModelAttribute] != null)
             {
                 bool elevationModel;
                 if (bool.TryParse(imageSet.Attributes[Constants.WTMLElevationModelAttribute].Value, out elevationModel))
                 {
                     wtmlDetails.IsElevationModel = elevationModel;
                 }
             }
             if (imageSet.Attributes[Constants.WTMLName] != null)
             {
                 wtmlDetails.Name = imageSet.Attributes[Constants.WTMLName].Value;
             }
             if (imageSet.Attributes[Constants.WTMLTileLevel] != null)
             {
                 wtmlDetails.Levels = imageSet.Attributes[Constants.WTMLTileLevel].Value;
             }
             if (imageSet.Attributes[Constants.WTMLProjection] != null)
             {
                 wtmlDetails.ProjectType = imageSet.Attributes[Constants.WTMLProjection].Value;
             }
             if (imageSet.Attributes[Constants.DEMUrl] != null)
             {
                 wtmlDetails.IsDemEnabled = true;
             }
             if (imageSet.SelectSingleNode(Constants.Credits) != null)
             {
                 wtmlDetails.Credit = imageSet.SelectSingleNode(Constants.Credits).InnerText;
             }
             if (imageSet.SelectSingleNode(Constants.CreditURL) != null)
             {
                 wtmlDetails.CreditPath = imageSet.SelectSingleNode(Constants.CreditURL).InnerText;
             }
         }
     }
     catch (XmlException ex)
     {
         ErrorHandler.LogException(ex);
         throw new FaultException(ex.Message);
     }
     catch (IOException ex)
     {
         ErrorHandler.LogException(ex);
         throw new FaultException(ex.Message);
     }
     catch (SecurityException ex)
     {
         ErrorHandler.LogException(ex);
         throw new FaultException(ex.Message);
     }
     return wtmlDetails;
 }