public static DeviceBitsGroup From(XElement xBits) { var res = new DeviceBitsGroup(); var xName = xBits.Attribute("name"); var xDescription = xBits.Element("description"); res.Name = xName != null ? xName.Value : ""; res.Description = DeviceInfoUtils.FormatDescription(xDescription); foreach (var xBit in xBits.Elements("deviceBit")) { res.Bits.Add(DeviceBit.From(xBit)); } return(res); }
public static DeviceBit From(XElement xDeviceBit) { var xAddress = xDeviceBit.Attribute("address"); var xBit = xDeviceBit.Attribute("bit"); var xName = xDeviceBit.Attribute("name"); var xInverse = xDeviceBit.Attribute("inverse"); var xConstant = xDeviceBit.Attribute("constant"); var xHidden = xDeviceBit.Attribute("hidden"); var xDescription = xDeviceBit.Element("description"); return(new DeviceBit { Address = xAddress != null?ParseInt(xAddress.Value) : 0, Bit = xBit != null?int.Parse(xBit.Value) : 0, Name = xName != null ? xName.Value : "", Inverse = xInverse != null && xInverse.Value.ToLowerInvariant() == "true", Hidden = xHidden != null && xHidden.Value.ToLowerInvariant() == "true", Constant = xConstant != null ? new bool?(xConstant.Value == "1") : null, Description = DeviceInfoUtils.FormatDescription(xDescription) }); }