Пример #1
0
        /// <summary>
        /// Returns the device identifier string created by combining the specified <see cref="IDeviceIdComponent"/> instances.
        /// </summary>
        /// <param name="components">A sequence containing the <see cref="IDeviceIdComponent"/> instances to combine into the device identifier string.</param>
        /// <returns>The device identifier string.</returns>
        public string GetDeviceId(IEnumerable <IDeviceIdComponent> components)
        {
            if (components == null)
            {
                throw new ArgumentNullException(nameof(components));
            }

            return(string.Join(".", components.OrderBy(x => x.Name).Select(x => _encoder.Encode(x))));
        }
Пример #2
0
 private string GetValue(IDeviceIdComponent component)
 {
     try
     {
         return(_encoder.Encode(component));
     }
     catch (DeviceIdComponentFailedToObtainValueException)
     {
         return("");
     }
 }
Пример #3
0
 /// <summary>
 /// Returns an <see cref="XElement"/> representing the specified <see cref="IDeviceIdComponent"/> instance.
 /// </summary>
 /// <param name="component">The <see cref="IDeviceIdComponent"/> to represent.</param>
 /// <returns>An <see cref="XElement"/> representing the specified <see cref="IDeviceIdComponent"/> instance.</returns>
 private XElement GetElement(IDeviceIdComponent component)
 {
     try
     {
         return(new XElement("Component",
                             new XAttribute("Name", component.Name),
                             new XAttribute("Value", _encoder.Encode(component))));
     }
     catch
     {
         return(new XElement("Component",
                             new XAttribute("Name", component.Name)));
     }
 }