Delegate 関係クラスのコンストラクタ

Delegate 関係クラスのコンストラクタの可視性に興味がでたのでメモ

下のソースの出力結果

--- Object
protected public Void .ctor()
--- Delegate
protected Void .ctor(System.Object, System.String)
protected Void .ctor(System.Type, System.String)
private Void .ctor()
--- MulticastDelegate
protected Void .ctor(System.Object, System.String)
protected Void .ctor(System.Type, System.String)

ソースの抜粋

public void PrintCtor(ConstructorInfo[] cs)
{
    foreach (ConstructorInfo c in cs)
    {
        if ((c.Attributes & MethodAttributes.Private) == MethodAttributes.Private) { Console.Write("private "); }
        if ((c.Attributes & MethodAttributes.Family) == MethodAttributes.Family) { Console.Write("protected "); }
        if ((c.Attributes & MethodAttributes.Public) == MethodAttributes.Public) { Console.Write("public "); }

        Console.WriteLine(c.ToString());
    }
}

private void PrintCtors(Type objty)
{
    Console.WriteLine("--- " + objty.Name);
    BindingFlags flg;
    flg = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
    ConstructorInfo[] cs = objty.GetConstructors(flg);
    PrintCtor(cs);
}

public void Main()
{
    PrintCtors(typeof(object));
    PrintCtors(typeof(Delegate));
    PrintCtors(typeof(MulticastDelegate));
    return;
}