Beispiel #1
0
 public static void UpdateSettingsDecode(Asn1TreeNode rootNode)
 {
     foreach (Asn1Lite node in rootNode.Flatten())
     {
         node.UpdateView();
     }
 }
Beispiel #2
0
 public static void UpdateSettingsInteger(Asn1TreeNode rootNode, IList <Byte> rawData)
 {
     if (Settings.Default.IntAsInt)
     {
         foreach (Asn1Lite node in rootNode.Flatten().Where(x => x.Tag == (Byte)Asn1Type.INTEGER))
         {
             Byte[] raw = rawData.Skip(node.PayloadStartOffset).Take(node.PayloadLength).ToArray();
             node.ExplicitValue = new BigInteger(raw.Reverse().ToArray()).ToString();
         }
     }
     else
     {
         foreach (Asn1Lite node in rootNode.Flatten().Where(x => x.Tag == (Byte)Asn1Type.INTEGER))
         {
             Byte[] raw = rawData.Skip(node.PayloadStartOffset).Take(node.PayloadLength).ToArray();
             node.ExplicitValue = AsnFormatter.BinaryToString(
                 raw,
                 EncodingType.HexRaw,
                 EncodingFormat.NOCRLF
                 );
         }
     }
 }
Beispiel #3
0
 public String RenderText(Int32 textWidth)
 {
     _sb.Clear();
     if (_rootNode == null)
     {
         return(_sb.ToString());
     }
     foreach (Asn1TreeNode node in _rootNode.Flatten())
     {
         String leftPad = getLeftPad(node);
         writeTagHeader(node, leftPad);
         if (!node.Value.IsContainer && node.Value.PayloadLength > 0)
         {
             writeContent(node, leftPad);
         }
     }
     return(_sb.ToString());
 }
Beispiel #4
0
        public String RenderText(Int32 textWidth)
        {
            width = textWidth;
            var sb = new StringBuilder("Offset|Length|LenByte|" + nl);

            if (rootNode == null)
            {
                return(sb.ToString());
            }

            sb.Append("======+======+=======+" + new String('=', width + 10) + nl);
            foreach (Asn1Lite node in rootNode.Flatten().Select(x => x.Value))
            {
                String padding = new String(' ', (node.Depth - rootNode.Value.Depth + 1) * 3);
                String str     = String.Format("{0,6}|{1,6}|{2,7}|{3}{4} : ",
                                               node.Offset,
                                               node.PayloadLength,
                                               node.HeaderLength - 1,
                                               padding,
                                               node.TagName);
                sb.Append(str + calculateValue(node, padding.Length));
            }
            return(sb.ToString());
        }