RunInstallerAttribute Klasa

Definicja

Określa, czy instalator akcji niestandardowej programu Visual Studio, czy Installutil.exe (narzędzie instalatora) powinny być wywoływane po zainstalowaniu zestawu.

public ref class RunInstallerAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public class RunInstallerAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type RunInstallerAttribute = class
    inherit Attribute
Public Class RunInstallerAttribute
Inherits Attribute
Dziedziczenie
RunInstallerAttribute
Atrybuty

Przykłady

Poniższy przykład określa, że instalator powinien zostać uruchomiony dla MyProjectInstallerprogramu .

[RunInstallerAttribute(true)]
ref class MyProjectInstaller: public Installer{
   // Insert code here.
};
[RunInstallerAttribute(true)]
 public class MyProjectInstaller : Installer {
    // Insert code here.
 }
<RunInstallerAttribute(True)> _
Public Class MyProjectInstaller
    Inherits Installer

    ' Insert code here.
End Class

W następnym przykładzie zostanie utworzone wystąpienie klasy MyProjectInstaller. Następnie pobiera atrybuty klasy, wyodrębnia RunInstallerAttributeelement i wyświetla, czy należy uruchomić instalatora.

int main()
{
   // Creates a new installer.
   MyProjectInstaller^ myNewProjectInstaller = gcnew MyProjectInstaller;

   // Gets the attributes for the collection.
   AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewProjectInstaller );

   /* Prints whether to run the installer by retrieving the 
       * RunInstallerAttribute from the AttributeCollection. */
   RunInstallerAttribute^ myAttribute = dynamic_cast<RunInstallerAttribute^>(attributes[ RunInstallerAttribute::typeid ]);
   Console::WriteLine( "Run the installer? {0}", myAttribute->RunInstaller );
   return 0;
}
public static int Main() {
    // Creates a new installer.
    MyProjectInstaller myNewProjectInstaller = new MyProjectInstaller();
 
    // Gets the attributes for the collection.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewProjectInstaller);
 
    /* Prints whether to run the installer by retrieving the 
     * RunInstallerAttribute from the AttributeCollection. */
    RunInstallerAttribute myAttribute = 
       (RunInstallerAttribute)attributes[typeof(RunInstallerAttribute)];
    Console.WriteLine("Run the installer? " + myAttribute.RunInstaller.ToString());
  
    return 0;
 }
Public Shared Function Main() As Integer
    ' Creates a new installer.
    Dim myNewProjectInstaller As New MyProjectInstaller()
    
    ' Gets the attributes for the collection.
    Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewProjectInstaller)
    
    ' Prints whether to run the installer by retrieving the
    ' RunInstallerAttribute from the AttributeCollection. 
    Dim myAttribute As RunInstallerAttribute = _
        CType(attributes(GetType(RunInstallerAttribute)), RunInstallerAttribute)

    Console.WriteLine(("Run the installer? " & myAttribute.RunInstaller.ToString()))
    Return 0
End Function 'Main

Uwagi

Jeśli klasa dziedziczona z Installer jest oznaczona za pomocą RunInstallerAttribute zestawu true, Instalator akcji niestandardowej programu Visual Studio lub InstallUtil.exe zostanie wywołany po zainstalowaniu zestawu. Członkowie oznaczeni zestawem RunInstallerAttributefalse nie będą wywoływać instalatora. Wartość domyślna to true.

Uwaga

Gdy oznaczysz właściwość z ustawioną RunInstallerAttribute wartością true, wartość tego atrybutu jest ustawiona na stały element członkowski Yes. Dla właściwości oznaczonej wartością ustawioną na RunInstallerAttributefalsewartość , wartość to No. W związku z tym, jeśli chcesz sprawdzić wartość tego atrybutu w kodzie, musisz określić atrybut jako RunInstallerAttribute.Yes lub RunInstallerAttribute.No.

Aby uzyskać więcej informacji, zobacz Atrybuty.

Konstruktory

RunInstallerAttribute(Boolean)

Inicjuje nowe wystąpienie klasy RunInstallerAttribute.

Pola

Default

Określa domyślną widoczność, czyli No. To static pole jest tylko do odczytu.

No

Określa, że instalator akcji niestandardowej programu Visual Studio lub Installutil.exe (narzędzie instalatora) nie powinien być wywoływany po zainstalowaniu zestawu. To static pole jest tylko do odczytu.

Yes

Określa, że podczas instalowania zestawu należy wywołać Instalatora akcji niestandardowej programu Visual Studio lub Installutil.exe (narzędzie instalatora ). To static pole jest tylko do odczytu.

Właściwości

RunInstaller

Pobiera wartość wskazującą, czy instalator powinien być wywoływany podczas instalacji zestawu.

TypeId

Po zaimplementowaniu w klasie pochodnej pobiera unikatowy identyfikator dla tego elementu Attribute.

(Odziedziczone po Attribute)

Metody

Equals(Object)

Określa, czy wartość określonego RunInstallerAttribute jest równoważna bieżącemu RunInstallerAttribute.

GetHashCode()

Generuje kod skrótu dla bieżącego RunInstallerAttributepliku .

GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
IsDefaultAttribute()

Określa, czy ten atrybut jest domyślny.

Match(Object)

W przypadku zastąpienia w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Pobiera informacje o typie obiektu, którego można użyć do pobrania informacji o typie interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy

Zobacz też