public MediaServerUpnPDeviceInformation(ILocalizedDeviceInformation copyDevice) { FriendlyName = copyDevice.GetFriendlyName(CultureInfo.InvariantCulture); Manufacturer = copyDevice.GetManufacturer(CultureInfo.InvariantCulture); ManufacturerURL = copyDevice.GetManufacturerURL(CultureInfo.InvariantCulture); ModelDescription = copyDevice.GetModelDescription(CultureInfo.InvariantCulture); ModelName = copyDevice.GetModelName(CultureInfo.InvariantCulture); ModelNumber = copyDevice.GetModelNumber(CultureInfo.InvariantCulture); ModelURL = copyDevice.GetModelURL(CultureInfo.InvariantCulture); SerialNumber = copyDevice.GetSerialNumber(CultureInfo.InvariantCulture); UPC = copyDevice.GetUPC(); Icons = GetIcons(CultureInfo.InvariantCulture); }
/// <summary> /// Creates the UPnP device description XML fragment for this device, all embedded devices and all services. /// </summary> /// <param name="writer">Result XML writer to add the device descriptions fragment to.</param> /// <param name="config">UPnP endpoint which will be used to create the endpoint specific information.</param> /// <param name="culture">Culture to create the culture specific information.</param> internal void AddDeviceDescriptionsRecursive(XmlWriter writer, EndpointConfiguration config, CultureInfo culture) { GenerateDescriptionDlgt dgh = DescriptionGenerateHook; ILocalizedDeviceInformation deviceInformation = _deviceInformation; writer.WriteStartElement("device"); if (dgh != null) { dgh(writer, this, GenerationPosition.DeviceStart, config, culture); } writer.WriteElementString("deviceType", DeviceTypeVersion_URN); writer.WriteElementString("friendlyName", deviceInformation.GetFriendlyName(culture)); writer.WriteElementString("manufacturer", deviceInformation.GetManufacturer(culture)); string manufacturerURL = deviceInformation.GetManufacturerURL(culture); if (!string.IsNullOrEmpty(manufacturerURL)) { writer.WriteElementString("manufacturerURL", manufacturerURL); } string modelDescription = deviceInformation.GetModelDescription(culture); if (!string.IsNullOrEmpty(modelDescription)) { writer.WriteElementString("modelDescription", modelDescription); } writer.WriteElementString("modelName", deviceInformation.GetModelName(culture)); string modelNumber = deviceInformation.GetModelNumber(culture); if (!string.IsNullOrEmpty(modelNumber)) { writer.WriteElementString("modelNumber", modelNumber); } string modelURL = deviceInformation.GetModelURL(culture); if (!string.IsNullOrEmpty(modelURL)) { writer.WriteElementString("modelURL", modelURL); } string serialNumber = deviceInformation.GetSerialNumber(culture); if (!string.IsNullOrEmpty(serialNumber)) { writer.WriteElementString("serialNumber", serialNumber); } writer.WriteElementString("UDN", UDN); string upc = deviceInformation.GetUPC(); if (!string.IsNullOrEmpty(upc)) { writer.WriteElementString("UPC", upc); } ICollection <IconDescriptor> icons = deviceInformation.GetIcons(culture); if (icons != null && icons.Count > 0) { writer.WriteStartElement("iconList"); foreach (IconDescriptor icon in icons) { writer.WriteStartElement("icon"); writer.WriteElementString("mimetype", icon.MimeType); writer.WriteElementString("width", icon.Width.ToString()); writer.WriteElementString("height", icon.Height.ToString()); writer.WriteElementString("depth", icon.ColorDepth.ToString()); writer.WriteElementString("url", icon.GetIconURLDelegate(config.EndPointIPAddress, culture)); writer.WriteEndElement(); // icon } writer.WriteEndElement(); // iconList } ICollection <DvService> services = _services; if (services.Count > 0) { writer.WriteStartElement("serviceList"); foreach (DvService service in services) { service.AddDeviceDescriptionForService(writer, config); } writer.WriteEndElement(); // serviceList } ICollection <DvDevice> embeddedDevices = _embeddedDevices; if (embeddedDevices.Count > 0) { writer.WriteStartElement("deviceList"); foreach (DvDevice embeddedDevice in embeddedDevices) { embeddedDevice.AddDeviceDescriptionsRecursive(writer, config, culture); } writer.WriteEndElement(); // deviceList } if (dgh != null) { dgh(writer, this, GenerationPosition.AfterDeviceList, config, culture); } GetURLForEndpointDlgt presentationURLGetter = GetPresentationURLDelegate; string presentationURL = null; if (presentationURLGetter != null) { presentationURL = presentationURLGetter(config.EndPointIPAddress, culture); } if (!string.IsNullOrEmpty(presentationURL)) { writer.WriteElementString("presentationURL", presentationURL); } if (dgh != null) { dgh(writer, this, GenerationPosition.DeviceEnd, config, culture); } writer.WriteEndElement(); // device }