internal Node CreateNodes() { var node = new Node(ActionBlock.ACTION_CHILD_NODE.ToLowerInvariant()); node.Attributes.Add(DEVICE_ATTRIBUTE, ActionDeviceHelper.ToString(device)); if (time != 0) { node.Attributes.Add(TIME_ATTRIBUTE, ConversionHelper.FormatHexUInt(time)); } node.Attributes.Add(USAGE_ATTRIBUTE, ConversionHelper.FormatHexUInt((uint)usage)); node.Attributes.Add(PAGE_ATTRIBUTE, ConversionHelper.FormatHexUInt(page)); if (value != 0) { node.Attributes.Add(VALUE_ATTRIBUTE, ConversionHelper.FormatHexUInt((uint)value)); } return(node); }
/// <summary> /// Creates a new Action. /// </summary> /// <param name="validator">The validator to use for validation.</param> /// <param name="node">The "action" node.</param> internal Action(NodeValidator validator, Node node) : base(validator, node) { if (node.Attributes.ContainsKey(DEVICE_ATTRIBUTE)) { device = ActionDeviceHelper.TryParse(node.Attributes[DEVICE_ATTRIBUTE]); } if (node.Attributes.ContainsKey(TIME_ATTRIBUTE)) { time = ConversionHelper.ParseHexValue(node.Attributes[TIME_ATTRIBUTE]); } if (node.Attributes.ContainsKey(USAGE_ATTRIBUTE)) { usage = (ActionKey)ConversionHelper.ParseHexValue(node.Attributes[USAGE_ATTRIBUTE]); } if (node.Attributes.ContainsKey(PAGE_ATTRIBUTE)) { page = ConversionHelper.ParseHexValue(node.Attributes[PAGE_ATTRIBUTE]); } if (node.Attributes.ContainsKey(VALUE_ATTRIBUTE)) { value = (ActionValue)ConversionHelper.ParseHexValue(node.Attributes[VALUE_ATTRIBUTE]); } }