/// <summary>
 /// Gets the device description for a device.
 /// </summary>
 /// <param name="device">The device to get the description for.</param>
 /// <param name="rootDescription">The root description for the device.</param>
 /// <returns>The device description or null if not found in the root description.</returns>
 public static DeviceDescription Description(this IUPnPDevice device, RootDescription rootDescription)
 {
     if (rootDescription != null)
         return rootDescription.FindDevice(device.UniqueDeviceName);
     else
         return null;
 }
 /// <summary>
 /// Gets the device description for a device.
 /// </summary>
 /// <param name="device">The device to get the description for.</param>
 /// <param name="rootDescription">The root description for the device.</param>
 /// <returns>The device description or null if not found in the root description.</returns>
 public static DeviceDescription Description(this IUPnPDevice device, RootDescription rootDescription)
 {
     if (rootDescription != null)
     {
         return(rootDescription.FindDevice(device.UniqueDeviceName));
     }
     else
     {
         return(null);
     }
 }
        /// <summary>
        /// Gets the description for a service.
        /// </summary>
        /// <param name="service">The native com service.</param>
        /// <param name="device">The native com device.</param>
        /// <param name="rootDescription">The root description for the services device.</param>
        /// <returns>The service description.</returns>
        public static ServiceDescription Description(
            this IUPnPService service, IUPnPDevice device, RootDescription rootDescription)
        {
            if (Logging.Enabled)
                Logging.Log(service, String.Format("Getting ServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), 1);

            try
            {
                DeviceServiceDescription ldsdDesc = service.DeviceServiceDescription(device, rootDescription);

                if (ldsdDesc != null)
                {
                    ServiceDescription lsdDesc = ldsdDesc.GetDescription(rootDescription);

                    if (lsdDesc != null)
                    {
                        if (Logging.Enabled)
                        {
                            if (Logging.Enabled)
                                Logging.Log(service, "ServiceDescription:", 1);

                            try
                            {
                                if (Logging.Enabled)
                                    Logging.Log(service, lsdDesc.ToString());
                            }
                            finally
                            {
                                if (Logging.Enabled)
                                    Logging.Log(service, "End ServiceDescription", -1);
                            }
                        }
                    }
                    else
                        if (Logging.Enabled)
                            Logging.Log(service, "ServiceDescription not found");

                    return lsdDesc;
                }
                else
                {
                    if (Logging.Enabled)
                        Logging.Log(service, "Failed - Device Service Description Not Located");
                    return null;
                }
            }
            finally
            {
                if (Logging.Enabled)
                    Logging.Log(service, String.Format("Finished getting ServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), -1);
            }
        }
        /// <summary>
        /// Process a URL, prepending the URL base if needed.
        /// </summary>
        /// <param name="root">The root description document.</param>
        /// <param name="url">The url to process</param>
        /// <returns>The URL or null if none.</returns>
        public string ProcessURL(RootDescription root, string url)
        {
            if (url.Length > 0)
            {
                string lsURLBase = URLBase(root);

                if (lsURLBase.Length > 0)
                {
                    return(Utils.CombineURL(lsURLBase, url));
                }
            }

            return(null);
        }
        /// <summary>
        /// Gets this device description with full service information.
        /// </summary>
        /// <param name="rootDescription">The root description.</param>
        /// <param name="indent">The indent for the string.</param>
        /// <returns>The string representation of the device.</returns>
        public string ToStringWithFullServices(RootDescription rootDescription, int indent = 0)
        {
            StringBuilder lsbBuilder = new StringBuilder();

            lsbBuilder.Append(ToString(indent).AsLine());

            foreach (DeviceServiceDescription lsService in DeviceServices.Values)
            {
                ServiceDescription lsdDesc = lsService.GetDescription(rootDescription);
                if (lsdDesc != null)
                {
                    lsbBuilder.Append(lsdDesc.ToString(indent).AsLine());
                }

                foreach (DeviceDescription ldDevice in Devices.Values)
                {
                    lsbBuilder.Append(ldDevice.ToStringWithFullServices(rootDescription, indent + 1).AsLine());
                }
            }

            return(lsbBuilder.ToString());
        }
 /// <summary>
 /// Gets the absolute URL to the SCPD document.
 /// </summary>
 /// <param name="root">The root description.</param>
 /// <returns>The URL or null if not available.</returns>
 public string GetSCPDURL(RootDescription root)
 {
     return(ProcessURL(root, SCPDURL));
 }
        /// <summary>
        /// Gets the service description for this service from the root description.
        /// </summary>
        /// <param name="root">The root description to get the service description from.</param>
        /// <returns>The service description or null if it cannot be located.</returns>
        public ServiceDescription GetDescription(RootDescription root)
        {
            if (Logging.Enabled)
            {
                Logging.Log(this, string.Format("Getting ServiceDescription for DeviceServiceDescription: '{0}'", this.ServiceId), 1);
            }

            try
            {
                string lsURL = ProcessURL(root, SCPDURL);

                if (!String.IsNullOrEmpty(lsURL))
                {
                    if (Logging.Enabled)
                    {
                        Logging.Log(this, string.Format("Combined URL: {0}", lsURL));
                    }

                    ServiceDescription lsdDesc = ServiceDescriptionCache.Cache.ByURL(lsURL);
                    if (lsdDesc != null)
                    {
                        if (Logging.Enabled)
                        {
                            Logging.Log(this, string.Format("Description Document found in cache by URL"));
                        }
                        return(lsdDesc);
                    }

                    if (Logging.Enabled)
                    {
                        Logging.Log(this, String.Format("Getting Document URL: '{0}'", lsURL));
                    }

                    try
                    {
                        using (XmlTextReader lrReader = Utils.GetXMLTextReader(lsURL))
                        {
                            if (Logging.Enabled)
                            {
                                Logging.Log(this, "Finding start node");
                            }

                            while (lrReader.Read())
                            {
                                if (ServiceDescription.IsStartNodeFor(lrReader))
                                {
                                    break;
                                }
                            }

                            if (ServiceDescription.IsStartNodeFor(lrReader))
                            {
                                if (Logging.Enabled)
                                {
                                    Logging.Log(this, "Start node found, processing description");
                                }
                                lsdDesc = new ServiceDescription(this, lsURL, Device.UDN, ServiceId, lrReader);
                            }
                        }
                    }
                    catch (Exception loE)
                    {
                        if (Logging.Enabled)
                        {
                            Logging.Log(this, String.Format("Downloading and processing of URL failed with error: {0}", loE.ToString()));
                        }
                        throw;
                    }

                    if (Logging.Enabled)
                    {
                        Logging.Log(this, "Adding to URL description document cache");
                    }
                    ServiceDescriptionCache.Cache.AddURL(lsURL, lsdDesc);

                    return(lsdDesc);
                }
                else
                {
                    return(null);
                }
            }
            finally
            {
                if (Logging.Enabled)
                {
                    Logging.Log(this, "Finished getting ServiceDescription", -1);
                }
            }
        }
        /// <summary>
        /// Gets the base URL for all URLs.
        /// </summary>
        /// <param name="root">The root description for the service description.</param>
        /// <returns>The URL base for all URLs for this service.</returns>
        public string URLBase(RootDescription root)
        {
            if (Logging.Enabled)
            {
                Logging.Log(this, string.Format("Getting Base URL for RootDescription: '{0}'", root.Device.FriendlyName), 1);
            }

            try
            {
                // Try using the root descriptions URL base
                string lsURLBase = root.URLBase;

                // If thats not there
                if (lsURLBase.Length == 0)
                {
                    // Use the base of the document URL
                    lsURLBase = root.DocumentURL;

                    if (Logging.Enabled)
                    {
                        Logging.Log(this, string.Format("URLBase element is empty, using relative path from: '{0}'", lsURLBase));
                    }

                    try
                    {
                        // Create a URI
                        if (Logging.Enabled)
                        {
                            Logging.Log(this, "Building URI");
                        }
                        Uri luURI = new Uri(lsURLBase);

                        // Get its parts
                        if (Logging.Enabled)
                        {
                            Logging.Log(this, "Getting segments");
                        }
                        string[] lsParts = luURI.Segments;

                        // Exclude the last part of the URI and use that as the base
                        if (lsParts.Length > 1)
                        {
                            lsURLBase = lsURLBase.Substring(0, lsURLBase.Length - lsParts[lsParts.Length - 1].Length);
                            if (Logging.Enabled)
                            {
                                Logging.Log(this, String.Format("Resulting Base URL: '{0}'", lsURLBase));
                            }
                        }
                        else
                        if (Logging.Enabled)
                        {
                            Logging.Log(this, String.Format("Not enoughs parts in base, using: '{0}'", lsURLBase));
                        }
                    }
                    catch (Exception loE)
                    {
                        if (Logging.Enabled)
                        {
                            Logging.Log(this, String.Format("Getting URLBase failed with exception: '{0}'", loE.ToString()));
                        }

                        // No base available (oops)
                        lsURLBase = string.Empty;
                    }
                }
                else
                if (Logging.Enabled)
                {
                    Logging.Log(this, string.Format("URLBase element found, using: '{0}'", lsURLBase));
                }

                // Return the base URL
                return(lsURLBase);
            }
            finally
            {
                if (Logging.Enabled)
                {
                    Logging.Log(this, "Finished getting Base URL for RootDescription", -1);
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Gets the description for a service.
        /// </summary>
        /// <param name="service">The native com service.</param>
        /// <param name="device">The native com device.</param>
        /// <param name="rootDescription">The root description for the services device.</param>
        /// <returns>The service description.</returns>
        public static ServiceDescription Description(
            this IUPnPService service, IUPnPDevice device, RootDescription rootDescription)
        {
            if (Logging.Enabled)
            {
                Logging.Log(service, String.Format("Getting ServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), 1);
            }

            try
            {
                DeviceServiceDescription ldsdDesc = service.DeviceServiceDescription(device, rootDescription);

                if (ldsdDesc != null)
                {
                    ServiceDescription lsdDesc = ldsdDesc.GetDescription(rootDescription);

                    if (lsdDesc != null)
                    {
                        if (Logging.Enabled)
                        {
                            if (Logging.Enabled)
                            {
                                Logging.Log(service, "ServiceDescription:", 1);
                            }

                            try
                            {
                                if (Logging.Enabled)
                                {
                                    Logging.Log(service, lsdDesc.ToString());
                                }
                            }
                            finally
                            {
                                if (Logging.Enabled)
                                {
                                    Logging.Log(service, "End ServiceDescription", -1);
                                }
                            }
                        }
                    }
                    else
                    if (Logging.Enabled)
                    {
                        Logging.Log(service, "ServiceDescription not found");
                    }

                    return(lsdDesc);
                }
                else
                {
                    if (Logging.Enabled)
                    {
                        Logging.Log(service, "Failed - Device Service Description Not Located");
                    }
                    return(null);
                }
            }
            finally
            {
                if (Logging.Enabled)
                {
                    Logging.Log(service, String.Format("Finished getting ServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), -1);
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// Gets the device service description for a service.
        /// </summary>
        /// <param name="service">The service to get the description for.</param>
        /// <param name="device">The device to get the description for.</param>
        /// <param name="rootDescription">The root description for the device.</param>
        /// <returns>The device service description.</returns>
        public static DeviceServiceDescription DeviceServiceDescription(
            this IUPnPService service, IUPnPDevice device, RootDescription rootDescription)
        {
            if (Logging.Enabled)
            {
                Logging.Log(service, String.Format("Getting DeviceServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), 1);
            }

            try
            {
                if (Logging.Enabled)
                {
                    if (Logging.Enabled)
                    {
                        Logging.Log(service, "Using RootDescription:", 1);
                    }

                    try
                    {
                        if (Logging.Enabled)
                        {
                            Logging.Log(service, rootDescription.ToString());
                        }
                    }
                    finally
                    {
                        if (Logging.Enabled)
                        {
                            Logging.Log(service, "End RootDescription", -1);
                        }
                    }
                }

                DeviceServiceDescription ldsdDesc = null;

                if (rootDescription != null)
                {
                    if (Logging.Enabled)
                    {
                        Logging.Log(service, string.Format("Finding device by UDN: '{0}'", device.UniqueDeviceName));
                    }
                    DeviceDescription lddDevice = rootDescription.FindDevice(device.UniqueDeviceName);

                    if (lddDevice != null)
                    {
                        if (Logging.Enabled)
                        {
                            Logging.Log(service, string.Format("Device Found, finding DeviceServiceDescription by Service ID: '{0}'", service.Id));
                        }

                        if (Logging.Enabled)
                        {
                            if (Logging.Enabled)
                            {
                                Logging.Log(service, "DeviceDescription:", 1);
                            }

                            try
                            {
                                if (Logging.Enabled)
                                {
                                    Logging.Log(service, lddDevice.ToString());
                                }
                            }
                            finally
                            {
                                if (Logging.Enabled)
                                {
                                    Logging.Log(service, "End DeviceDescription", -1);
                                }
                            }
                        }

                        lddDevice.DeviceServices.TryGetValue(service.Id, out ldsdDesc);

                        if (ldsdDesc != null)
                        {
                            if (Logging.Enabled)
                            {
                                if (Logging.Enabled)
                                {
                                    Logging.Log(service, "DeviceServiceDescription found:", 1);
                                }

                                try
                                {
                                    if (Logging.Enabled)
                                    {
                                        Logging.Log(service, ldsdDesc.ToString());
                                    }
                                }
                                finally
                                {
                                    if (Logging.Enabled)
                                    {
                                        Logging.Log(service, "End DeviceServiceDescription", -1);
                                    }
                                }
                            }
                        }
                        else
                        if (Logging.Enabled)
                        {
                            Logging.Log(service, "DeviceServiceDescripton not found");
                        }
                    }
                    else
                    if (Logging.Enabled)
                    {
                        Logging.Log(service, "Device not found");
                    }
                }
                else
                if (Logging.Enabled)
                {
                    Logging.Log(service, "Invalid rootDescription parameter");
                }

                return(ldsdDesc);
            }
            finally
            {
                if (Logging.Enabled)
                {
                    Logging.Log(service, String.Format("Finished getting DeviceServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), -1);
                }
            }
        }
        /// <summary>
        /// Gets the service description for this service from the root description.
        /// </summary>
        /// <param name="root">The root description to get the service description from.</param>
        /// <returns>The service description or null if it cannot be located.</returns>
        public ServiceDescription GetDescription(RootDescription root)
        {
            if (Logging.Enabled)
                Logging.Log(this, string.Format("Getting ServiceDescription for DeviceServiceDescription: '{0}'", this.ServiceId), 1);

            try
            {
                string lsURLBase = URLBase(root);

                if (lsURLBase.Length > 0 && SCPDURL.Length > 0)
                {
                    string lsURL = Utils.CombineURL(lsURLBase, SCPDURL);
                    if (Logging.Enabled)
                        Logging.Log(this, string.Format("Combined URL: {0}", lsURL));

                    ServiceDescription lsdDesc = ServiceDescriptionCache.Cache.ByURL(lsURL);
                    if (lsdDesc != null)
                    {
                        if (Logging.Enabled)
                            Logging.Log(this, string.Format("Description Document found in cache by URL"));
                        return lsdDesc;
                    }

                    if (Logging.Enabled)
                        Logging.Log(this, String.Format("Getting Document URL: '{0}'", lsURL));

                    try
                    {
                        using (XmlTextReader lrReader = Utils.GetXMLTextReader(lsURL))
                        {
                            if (Logging.Enabled)
                                Logging.Log(this, "Finding start node");

                            while (lrReader.Read())
                                if (ServiceDescription.IsStartNodeFor(lrReader)) break;

                            if (ServiceDescription.IsStartNodeFor(lrReader))
                            {
                                if (Logging.Enabled)
                                    Logging.Log(this, "Start node found, processing description");
                                lsdDesc = new ServiceDescription(this, lsURL, Device.UDN, ServiceId, lrReader);
                            }
                        }
                    }
                    catch (Exception loE)
                    {
                        if (Logging.Enabled)
                            Logging.Log(this, String.Format("Downloading and processing of URL failed with error: {0}", loE.ToString()));
                        throw;
                    }

                    if (Logging.Enabled)
                        Logging.Log(this, "Adding to URL description document cache");
                    ServiceDescriptionCache.Cache.AddURL(lsURL, lsdDesc);

                    return lsdDesc;
                }
                else
                    return null;
            }
            finally
            {
                if (Logging.Enabled)
                    Logging.Log(this, "Finished getting ServiceDescription", -1);
            }
        }
        /// <summary>
        /// Gets the device service description for a service.
        /// </summary>
        /// <param name="service">The service to get the description for.</param>
        /// <param name="device">The device to get the description for.</param>
        /// <param name="rootDescription">The root description for the device.</param>
        /// <returns>The device service description.</returns>
        public static DeviceServiceDescription DeviceServiceDescription(
            this IUPnPService service, IUPnPDevice device, RootDescription rootDescription)
        {
            if (Logging.Enabled)
                Logging.Log(service, String.Format("Getting DeviceServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), 1);

            try
            {
                if (Logging.Enabled)
                {
                    if (Logging.Enabled)
                        Logging.Log(service, "Using RootDescription:", 1);

                    try
                    {
                        if (Logging.Enabled)
                            Logging.Log(service, rootDescription.ToString());
                    }
                    finally
                    {
                        if (Logging.Enabled)
                            Logging.Log(service, "End RootDescription", -1);
                    }
                }

                DeviceServiceDescription ldsdDesc = null;

                if (rootDescription != null)
                {
                    if (Logging.Enabled)
                        Logging.Log(service, string.Format("Finding device by UDN: '{0}'", device.UniqueDeviceName));
                    DeviceDescription lddDevice = rootDescription.FindDevice(device.UniqueDeviceName);

                    if (lddDevice != null)
                    {
                        if (Logging.Enabled)
                            Logging.Log(service, string.Format("Device Found, finding DeviceServiceDescription by Service ID: '{0}'", service.Id));

                        if (Logging.Enabled)
                        {
                            if (Logging.Enabled)
                                Logging.Log(service, "DeviceDescription:", 1);

                            try
                            {
                                if (Logging.Enabled)
                                    Logging.Log(service, lddDevice.ToString());
                            }
                            finally
                            {
                                if (Logging.Enabled)
                                    Logging.Log(service, "End DeviceDescription", -1);
                            }
                        }

                        lddDevice.DeviceServices.TryGetValue(service.Id, out ldsdDesc);

                        if (ldsdDesc != null)
                        {
                            if (Logging.Enabled)
                            {
                                if (Logging.Enabled)
                                    Logging.Log(service, "DeviceServiceDescription found:", 1);

                                try
                                {
                                    if (Logging.Enabled)
                                        Logging.Log(service, ldsdDesc.ToString());
                                }
                                finally
                                {
                                    if (Logging.Enabled)
                                        Logging.Log(service, "End DeviceServiceDescription", -1);
                                }
                            }
                        }
                        else
                            if (Logging.Enabled)
                                Logging.Log(service, "DeviceServiceDescripton not found");
                    }
                    else
                        if (Logging.Enabled)
                            Logging.Log(service, "Device not found");
                }
                else
                    if (Logging.Enabled)
                        Logging.Log(service, "Invalid rootDescription parameter");

                return ldsdDesc;
            }
            finally
            {
                if (Logging.Enabled)
                    Logging.Log(service, String.Format("Finished getting DeviceServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), -1);
            }
        }
        /// <summary>
        /// Gets the root description for a device.
        /// </summary>
        /// <param name="device">The device to get the root description.</param>
        /// <returns>The root description for the device.</returns>
        public static RootDescription RootDeviceDescription(this IUPnPDevice device)
        {
            if (Logging.Enabled)
            {
                Logging.Log(device, String.Format("Getting RootDeviceDescription for {0}", device.FriendlyName), 1);
            }

            try
            {
                string lsURL = device.GetDocumentURL();

                if (lsURL.Length > 0)
                {
                    if (Logging.Enabled)
                    {
                        Logging.Log(device, String.Format("Getting Document URL: '{0}'", lsURL));
                    }

                    try
                    {
                        using (XmlTextReader lrReader = Utils.GetXMLTextReader(lsURL))
                        {
                            if (Logging.Enabled)
                            {
                                Logging.Log(device, "Finding start node");
                            }

                            while (lrReader.Read())
                            {
                                if (RootDescription.IsStartNodeFor(lrReader))
                                {
                                    break;
                                }
                            }

                            if (RootDescription.IsStartNodeFor(lrReader))
                            {
                                if (Logging.Enabled)
                                {
                                    Logging.Log(device, "Start node found, processing description");
                                }
                                return(new RootDescription(lsURL, lrReader));
                            }
                            else
                            {
                                if (Logging.Enabled)
                                {
                                    Logging.Log(device, "Start node NOT found");
                                }
                                return(null);
                            }
                        }
                    }
                    catch (Exception loE)
                    {
                        if (Logging.Enabled)
                        {
                            Logging.Log(device, String.Format("Downloading and processing of URL failed with error: {0}", loE.ToString()));
                        }
                        throw;
                    }
                }
                else
                {
                    if (Logging.Enabled)
                    {
                        Logging.Log(device, String.Format("Document URL Invalid: '{0}'", lsURL));
                    }
                    return(null);
                }
            }
            finally
            {
                if (Logging.Enabled)
                {
                    Logging.Log(device, System.String.Format("Finished getting RootDeviceDescription for {0}", device.FriendlyName), -1);
                }
            }
        }
        /// <summary>
        /// Gets this device description with full service information.
        /// </summary>
        /// <param name="rootDescription">The root description.</param>
        /// <param name="indent">The indent for the string.</param>
        /// <returns>The string representation of the device.</returns>
        public string ToStringWithFullServices(RootDescription rootDescription, int indent = 0)
        {
            StringBuilder lsbBuilder = new StringBuilder();

            lsbBuilder.Append(ToString(indent).AsLine());

            foreach (DeviceServiceDescription lsService in DeviceServices.Values)
            {
                ServiceDescription lsdDesc = lsService.GetDescription(rootDescription);
                if (lsdDesc != null) lsbBuilder.Append(lsdDesc.ToString(indent).AsLine());

                foreach (DeviceDescription ldDevice in Devices.Values)
                    lsbBuilder.Append(ldDevice.ToStringWithFullServices(rootDescription, indent + 1).AsLine());
            }

            return lsbBuilder.ToString();
        }
 /// <summary>
 /// Gets the absolute URL to the control URL.
 /// </summary>
 /// <param name="root">The root description.</param>
 /// <returns>The URL or null if not available.</returns>
 public string GetControlURL(RootDescription root)
 {
     return(ProcessURL(root, ControlURL));
 }
 /// <summary>
 /// Gets the absolute URL to the event sub URL.
 /// </summary>
 /// <param name="root">The root description.</param>
 /// <returns>The URL or null if not available.</returns>
 public string GetEventSubURL(RootDescription root)
 {
     return(ProcessURL(root, EventSubURL));
 }
        /// <summary>
        /// Gets the base URL for all URLs.
        /// </summary>
        /// <param name="root">The root description for the service description.</param>
        /// <returns>The URL base for all URLs for this service.</returns>
        public string URLBase(RootDescription root)
        {
            if (Logging.Enabled)
                Logging.Log(this, string.Format("Getting Base URL for RootDescription: '{0}'", root.Device.FriendlyName), 1);

            try
            {
                // Try using the root descriptions URL base
                string lsURLBase = root.URLBase;

                // If thats not there
                if (lsURLBase.Length == 0)
                {
                    // Use the base of the document URL
                    lsURLBase = root.DocumentURL;

                    if (Logging.Enabled)
                        Logging.Log(this, string.Format("URLBase element is empty, using relative path from: '{0}'", lsURLBase));

                    try
                    {
                        // Create a URI
                        if (Logging.Enabled)
                            Logging.Log(this, "Building URI");
                        Uri luURI = new Uri(lsURLBase);

                        // Get its parts
                        if (Logging.Enabled)
                            Logging.Log(this, "Getting segments");
                        string[] lsParts = luURI.Segments;

                        // Exclude the last part of the URI and use that as the base
                        if (lsParts.Length > 1)
                        {
                            lsURLBase = lsURLBase.Substring(0, lsURLBase.Length - lsParts[lsParts.Length - 1].Length);
                            if (Logging.Enabled)
                                Logging.Log(this, String.Format("Resulting Base URL: '{0}'", lsURLBase));
                        }
                        else
                            if (Logging.Enabled)
                                Logging.Log(this, String.Format("Not enoughs parts in base, using: '{0}'", lsURLBase));
                    }
                    catch (Exception loE)
                    {
                        if (Logging.Enabled)
                            Logging.Log(this, String.Format("Getting URLBase failed with exception: '{0}'", loE.ToString()));

                        // No base available (oops)
                        lsURLBase = string.Empty;
                    }
                }
                else
                    if (Logging.Enabled)
                        Logging.Log(this, string.Format("URLBase element found, using: '{0}'", lsURLBase));

                // Return the base URL
                return lsURLBase;
            }
            finally
            {
                if (Logging.Enabled)
                    Logging.Log(this, "Finished getting Base URL for RootDescription", -1);
            }
        }