RunInstallerAttribute Třída

Definice

Určuje, jestli se má při instalaci sestavení vyvolat Visual Studio instalační program vlastních akcí nebo Installutil.exe (instalační nástroj).

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
Dědičnost
RunInstallerAttribute
Atributy

Příklady

Následující příklad určuje, že instalační program by měl být spuštěn pro 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

Další příklad vytvoří instanci MyProjectInstaller. Potom získá atributy pro třídu, extrahuje RunInstallerAttributea vytiskne, zda se má spustit instalační program.

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

Poznámky

Pokud je třída, která dědí z Installer označena parametrem RunInstallerAttribute nastavenou na true, bude při instalaci sestavení vyvolán vlastní instalační program akcí Visual Studio nebo InstallUtil.exe. Členové označené nastavenou sadou RunInstallerAttribute nebudou false volat instalační program. Výchozí hodnota je true.

Note

Když označíte vlastnost nastavenou RunInstallerAttribute na truehodnotu , hodnota tohoto atributu je nastavena na konstantní člen Yes. Pro vlastnost označenou nastavenou RunInstallerAttribute na falsehodnotu je Nohodnota . Proto pokud chcete zkontrolovat hodnotu tohoto atributu v kódu, musíte zadat atribut jako RunInstallerAttribute.Yes nebo RunInstallerAttribute.No.

Další informace naleznete v tématu Atributy.

Konstruktory

Name Description
RunInstallerAttribute(Boolean)

Inicializuje novou instanci RunInstallerAttribute třídy.

Pole

Name Description
Default

Určuje výchozí viditelnost, což je No. Toto static pole je jen pro čtení.

No

Určuje, že instalační program Visual Studio vlastních akcí nebo instalační program Installutil.exe (instalační nástroj) by se při instalaci sestavení neměl vyvolat. Toto static pole je jen pro čtení.

Yes

Určuje, že se má při instalaci sestavení vyvolat Visual Studio instalační program vlastních akcí nebo Installutil.exe (instalační nástroj). Toto static pole je jen pro čtení.

Vlastnosti

Name Description
RunInstaller

Získá hodnotu určující, zda instalační program má být vyvolán během instalace sestavení.

TypeId

Při implementaci v odvozené třídě získá jedinečný identifikátor pro tento Attribute.

(Zděděno od Attribute)

Metody

Name Description
Equals(Object)

Určuje, zda je hodnota zadané RunInstallerAttribute hodnoty ekvivalentní aktuálnímu RunInstallerAttribute.

GetHashCode()

Vygeneruje kód hash pro aktuální RunInstallerAttribute.

GetType()

Získá Type aktuální instance.

(Zděděno od Object)
IsDefaultAttribute()

Určuje, zda je tento atribut výchozí.

Match(Object)

Při přepsání v odvozené třídě vrátí hodnotu, která určuje, zda se tato instance rovná zadanému objektu.

(Zděděno od Attribute)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Explicitní implementace rozhraní

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

Mapuje sadu názvů na odpovídající sadu identifikátorů pro rozesílání.

(Zděděno od Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Načte informace o typu objektu, který lze použít k získání informací o typu pro rozhraní.

(Zděděno od Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Získá počet rozhraní typu informací, které objekt poskytuje (0 nebo 1).

(Zděděno od Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Poskytuje přístup k vlastnostem a metodám vystaveným objektem.

(Zděděno od Attribute)

Platí pro

Viz také