Assembly.GetExportedTypes Metodo

Definizione

Ottiene i tipi pubblici definiti nell'assembly visibili all'esterno dell'assembly.Gets the public types defined in this assembly that are visible outside the assembly.

public:
 virtual cli::array <Type ^> ^ GetExportedTypes();
public virtual Type[] GetExportedTypes ();
abstract member GetExportedTypes : unit -> Type[]
override this.GetExportedTypes : unit -> Type[]
Public Overridable Function GetExportedTypes () As Type()

Restituisce

Type[]

Matrice che rappresenta i tipi definiti nell'assembly visibili all'esterno dell'assembly.An array that represents the types defined in this assembly that are visible outside the assembly.

Implementazioni

Eccezioni

L'assembly è un assembly dinamico.The assembly is a dynamic assembly.

Non è possibile caricare un assembly dipendente.Unable to load a dependent assembly.

Esempi

L'esempio di codice seguente definisce una serie di classi con diversi livelli di accesso e chiama GetExportedTypes per visualizzare quelli visibili dall'esterno dell'assembly.The following code sample defines a number of classes with various access levels, and calls GetExportedTypes to display the ones that are visible from outside the assembly.

using namespace System;
using namespace System::Reflection;

namespace ExportedClassExample
{
    public ref class Example sealed
    {
    private:
        Example() 
        {
        }

    public:
        void static EnumerateExportedTypes()
        {
            for each (Type^ exportedType in 
                Example::typeid->Assembly->GetExportedTypes())
            {
                Console::WriteLine(exportedType);
            }
        }
    };

    public ref class PublicClass
    {
    public:
        ref class PublicNestedClass 
        { 
        };

    protected:
        ref class ProtectedNestedClass 
        { 
        };

    internal:
        ref class FriendNestedClass 
        { 
        };

    private:
        ref class PrivateNestedClass
        { 
        };
    };

    ref class FriendClass
    {
    public:
        ref class PublicNestedClass
        { 
        };

    protected:
        ref class ProtectedNestedClass 
        { 
        };

    internal:
        ref class FriendNestedClass 
        { 
        };

    private:
        ref class PrivateNestedClass 
        { 
        };
    };
}

int main()
{
    ExportedClassExample::Example::EnumerateExportedTypes();

    return 0;
}
using System;
using System.Reflection;

public class Example
{
    public static void Main()
    {
        foreach (Type t in typeof(Example).Assembly.GetExportedTypes())
        {
            Console.WriteLine(t);
        }
    }
}

public class PublicClass
{
    public class PublicNestedClass {}

    protected class ProtectedNestedClass {}
 
    internal class FriendNestedClass {}

    private class PrivateNestedClass {}
}

internal class FriendClass
{
    public class PublicNestedClass {}

    protected class ProtectedNestedClass {}

    internal class FriendNestedClass {}

    private class PrivateNestedClass {}
}
Imports System.Reflection

Public Class Example
    Public Shared Sub Main()
        For Each t As Type In GetType(Example).Assembly.GetExportedTypes()
            Console.WriteLine(t)
        Next
    End Sub
End Class

Public Class PublicClass
    Public Class PublicNestedClass
    End Class

    Protected Class ProtectedNestedClass
    End Class

    Friend Class FriendNestedClass
    End Class

    Private Class PrivateNestedClass
    End Class
End Class

Friend Class FriendClass
    Public Class PublicNestedClass
    End Class

    Protected Class ProtectedNestedClass
    End Class

    Friend Class FriendNestedClass
    End Class

    Private Class PrivateNestedClass
    End Class
End Class

Commenti

Gli unici tipi visibili all'esterno di un assembly sono i tipi pubblici e i tipi pubblici annidati all'interno di altri tipi pubblici.The only types visible outside an assembly are public types and public types nested within other public types.

Si applica a