Ejemplo n.º 1
0
        /// <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());
        }
Ejemplo n.º 2
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);
                }
            }
        }