public static TreeNode fromTLV(TLV data) { if (data == null) { return(null); } TreeNode result = new TreeNode(data.Tag); result.Name = data.Tag; // put the Length, Value, Description string[] content = { Conversion_BER_TLV.ConvertFromInt(data.Length), data.Value, data.Description }; result.Tag = content; //traverse each child if (data.child != null) { foreach (var child in data.child) { if (child != null) { result.Nodes.Add(DataConverter.fromTLV(child)); } } } return(result); }
public void TestBERTLVConvertFromInt() { int val = 200; string tes = Conversion_BER_TLV.ConvertFromInt(val); Assert.AreEqual("81C8", tes); val = 14; tes = Conversion_BER_TLV.ConvertFromInt(val); Assert.AreEqual("0E", tes); val = 3399; tes = Conversion_BER_TLV.ConvertFromInt(val); Assert.AreEqual("820D47", tes); val = 128; tes = Conversion_BER_TLV.ConvertFromInt(val); Assert.AreEqual("8180", tes); }