Created
March 22, 2018 18:04
-
-
Save WamWooWam/d3f8692f2eb111db8e2b6e3216119963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (var a in p.CustomAttributes) | |
{ | |
Type at = a.AttributeType; | |
if (!at.Namespace.StartsWith("System.Runtime.InteropServices")) | |
{ | |
b.Append("["); | |
string name = at.Name; | |
b.Append(name.Substring(0, name.Length - 9)); | |
if (a.ConstructorArguments.Any() || a.NamedArguments.Any()) | |
{ | |
b.Append("("); | |
var cps = a.Constructor.GetParameters(); | |
for(int i = 0; i < cps.Length; i++) | |
{ | |
if (i != 0) | |
{ | |
b.Append(", "); | |
} | |
var ap = a.ConstructorArguments.ElementAt(i); | |
var cp = cps.ElementAt(i); | |
b.Append($"{cp.Name}: {ap.Value}"); | |
} | |
for(int i = 0; i < a.NamedArguments.Count; i++) | |
{ | |
if(i != 0 || a.ConstructorArguments.Any()) | |
{ | |
b.Append(", "); | |
} | |
var op = a.NamedArguments.ElementAt(i); | |
b.Append($"{op.MemberName} = {op.TypedValue.Value}"); | |
} | |
b.Append(")"); | |
} | |
b.Append("] "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment