Ildasm.Disassembler.DecodeDeclSecurity C# (CSharp) Method

DecodeDeclSecurity() private method

private DecodeDeclSecurity ( System.StringBuilder sb, IList list, int level ) : bool
sb System.StringBuilder
list IList
level int
return bool
        bool DecodeDeclSecurity(StringBuilder sb, IList<CustomAttributeData> list, int level)
        {
            try
            {
                sb.Append("           = {");
                bool first = true;
                foreach (var sec in list)
                {
                    if (!first)
                    {
                        sb.Append(',');
                        sb.AppendLine();
                        sb.Append(' ', level + 14);
                    }
                    first = false;
                    string typeName = sec.Constructor.DeclaringType.AssemblyQualifiedName;
                    if (typeName.EndsWith(", mscorlib", StringComparison.Ordinal))
                    {
                        typeName = typeName.Substring(0, typeName.Length - 10);
                    }
                    AppendTypeName(sb, sec.Constructor.DeclaringType, typeName, compat != CompatLevel.None);
                    sb.Append(" = {");
                    byte[] blob = sec.__GetBlob();
                    // LAMESPEC the count of named arguments is a compressed integer (instead of UInt16 as NumNamed in custom attributes)
                    var br = new ByteReader(blob, 0, blob.Length);
                    int count = br.ReadCompressedInt();
                    ReadNamedArguments(sb, br, count, 0, compat != CompatLevel.None && count > 1);
                    sb.Append('}');
                }
                sb.Append('}');
                return true;
            }
            catch (Managed.Reflection.BadImageFormatException)
            {
                return false;
            }
        }