Example #1
0
        /// <summary>
        ///     Converts a TLVData into an XmlNode representation, enhanced with the long name of the field found in the
        ///     <paramref name="dictionary" />
        /// </summary>
        /// <param name="tlv">Source data to convert</param>
        /// <param name="xmlDoc">XML document used to create elements</param>
        /// <param name="dictionary">TLV Dictionary to use to find the long name</param>
        /// <returns>A new XmlNode</returns>
        public static XElement ToXmlNode(this TlvData tlv, XDocument xmlDoc, TlvDictionary dictionary)
        {
            var xmlNode = tlv.ToXmlNode(xmlDoc);

            InsertDictionaryInformation(xmlNode, dictionary);
            InsertDictionaryInformation(xmlNode.Descendants("tlvData"), dictionary);

            return(xmlNode);
        }
Example #2
0
        private static void InsertDictionaryInformation(XElement xmlNode, TlvDictionary dictionary)
        {
            var description = dictionary.Get(xmlNode.Attribute("tag").Value);

            if (description != null)
            {
                xmlNode.Ancestors().Last().SetAttributeValue("longName", description.LongName);
            }
        }
Example #3
0
 private static void InsertDictionaryInformation(IEnumerable <XElement> xmlNodeList, TlvDictionary dictionary)
 {
     foreach (var xmlNode in xmlNodeList)
     {
         InsertDictionaryInformation(xmlNode, dictionary);
         InsertDictionaryInformation(xmlNode.Descendants("tlvData"), dictionary);
     }
 }
Example #4
0
 /// <summary>
 ///     Export a TLV object to XML format using a dictionnary to resolve formating
 /// </summary>
 /// <param name="tlv">Source object</param>
 /// <param name="dictionary">TLV Dictionary to use to find the long name</param>
 /// <returns>The <c>string</c> representation</returns>
 public static string ToXmlString(this TlvData tlv, TlvDictionary dictionary)
 {
     return(tlv.ToXmlNode(new XDocument(), dictionary).Value);
 }