RunInstallerAttribute Klasa
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Określa, czy instalator akcji niestandardowej Visual Studio, czy Installutil.exe (narzędzie instalatora) należy wywołać 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
- Atrybuty
Przykłady
W poniższym przykładzie określono, że instalator powinien zostać uruchomiony dla programu MyProjectInstaller.
[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 RunInstallerAttribute ustawiona na true, instalator akcji niestandardowej Visual Studio lub InstallUtil.exe zostanie wywołany po zainstalowaniu zestawu. Członkowie oznaczeni zestawem RunInstallerAttribute nie false będą wywoływać instalatora. Wartość domyślna to true.
Note
Gdy oznaczysz właściwość z RunInstallerAttribute ustawioną wartością true, wartość tego atrybutu jest ustawiona na stały element członkowski Yes. Dla właściwości oznaczonej wartością ustawioną RunInstallerAttribute na false, 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
| Nazwa | Opis |
|---|---|
| RunInstallerAttribute(Boolean) |
Inicjuje nowe wystąpienie klasy RunInstallerAttribute. |
Pola
| Nazwa | Opis |
|---|---|
| Default |
Określa domyślną widoczność, czyli No. To |
| No |
Określa, że instalator akcji niestandardowej Visual Studio lub Installutil.exe (narzędzie instalatora) nie powinien być wywoływany podczas instalowania zestawu. To |
| Yes |
Określa, że instalator akcji niestandardowej Visual Studio lub Installutil.exe (narzędzie instalatora) należy wywołać podczas instalowania zestawu. To |
Właściwości
| Nazwa | Opis |
|---|---|
| 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 Attribute. (Odziedziczone po Attribute) |
Metody
| Nazwa | Opis |
|---|---|
| Equals(Object) |
Określa, czy wartość określonego RunInstallerAttribute elementu jest równoważna bieżącemu RunInstallerAttributewartości . |
| GetHashCode() |
Generuje kod skrótu dla bieżącego RunInstallerAttributeelementu . |
| GetType() |
Pobiera Type bieżącego wystąpienia. (Odziedziczone po Object) |
| IsDefaultAttribute() |
Określa, czy ten atrybut jest domyślny. |
| Match(Object) |
Po zastąpieniu 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 Object. (Odziedziczone po Object) |
| ToString() |
Zwraca ciąg reprezentujący bieżący obiekt. (Odziedziczone po Object) |
Jawne implementacje interfejsu
| Nazwa | Opis |
|---|---|
| _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 uzyskania informacji o typie dla 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) |
Zapewnia dostęp do właściwości i metod uwidocznionych przez obiekt. (Odziedziczone po Attribute) |