AssemblyCompanyAttribute Osztály

Definíció

Egy szerelvényjegyzékhez tartozó vállalatnév egyéni attribútumát határozza meg.

public ref class AssemblyCompanyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
public sealed class AssemblyCompanyAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false)]
public sealed class AssemblyCompanyAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyCompanyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
type AssemblyCompanyAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false)>]
type AssemblyCompanyAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type AssemblyCompanyAttribute = class
    inherit Attribute
Public NotInheritable Class AssemblyCompanyAttribute
Inherits Attribute
Öröklődés
AssemblyCompanyAttribute
Attribútumok

Példák

Az alábbi példa bemutatja, hogyan alkalmazhat attribútumokat, beleértve az AssemblyCompanyAttribute attribútumot is egy dinamikus szerelvényre. A példa menti a szerelvényt a lemezre, és az attribútum értéke a Windows Fájl tulajdonságai párbeszédpanelen tekinthető meg.

using System;
using System.Reflection;
using System.Reflection.Emit;

class Example
{
   public static void Main()
   {
      AssemblyName assemName = new AssemblyName();
      assemName.Name = "EmittedAssembly";

      // Create a dynamic assembly in the current application domain,
      // specifying that the assembly is to be saved.
      //
      AssemblyBuilder myAssembly =
         AppDomain.CurrentDomain.DefineDynamicAssembly(assemName,
            AssemblyBuilderAccess.Save);

      // To apply an attribute to a dynamic assembly, first get the
      // attribute type. The AssemblyFileVersionAttribute sets the
      // File Version field on the Version tab of the Windows file
      // properties dialog.
      //
      Type attributeType = typeof(AssemblyFileVersionAttribute);

      // To identify the constructor, use an array of types representing
      // the constructor's parameter types. This ctor takes a string.
      //
      Type[] ctorParameters = { typeof(string) };

      // Get the constructor for the attribute.
      //
      ConstructorInfo ctor = attributeType.GetConstructor(ctorParameters);

      // Pass the constructor and an array of arguments (in this case,
      // an array containing a single string) to the
      // CustomAttributeBuilder constructor.
      //
      object[] ctorArgs = { "2.0.3033.0" };
      CustomAttributeBuilder attribute =
         new CustomAttributeBuilder(ctor, ctorArgs);

      // Finally, apply the attribute to the assembly.
      //
      myAssembly.SetCustomAttribute(attribute);

      // The pattern described above is used to create and apply
      // several more attributes. As it happens, all these attributes
      // have a constructor that takes a string, so the same ctorArgs
      // variable works for all of them.

      // The AssemblyTitleAttribute sets the Description field on
      // the General tab and the Version tab of the Windows file
      // properties dialog.
      //
      attributeType = typeof(AssemblyTitleAttribute);
      ctor = attributeType.GetConstructor(ctorParameters);
      ctorArgs = new object[] { "The Application Title" };
      attribute = new CustomAttributeBuilder(ctor, ctorArgs);
      myAssembly.SetCustomAttribute(attribute);

      // The AssemblyCopyrightAttribute sets the Copyright field on
      // the Version tab.
      //
      attributeType = typeof(AssemblyCopyrightAttribute);
      ctor = attributeType.GetConstructor(ctorParameters);
      ctorArgs = new object[] { "© My Example Company 1991-2005" };
      attribute = new CustomAttributeBuilder(ctor, ctorArgs);
      myAssembly.SetCustomAttribute(attribute);

      // The AssemblyDescriptionAttribute sets the Comment item.
      //
      attributeType = typeof(AssemblyDescriptionAttribute);
      ctor = attributeType.GetConstructor(ctorParameters);
      attribute = new CustomAttributeBuilder(ctor,
         new object[] { "This is a comment." });
      myAssembly.SetCustomAttribute(attribute);

      // The AssemblyCompanyAttribute sets the Company item.
      //
      attributeType = typeof(AssemblyCompanyAttribute);
      ctor = attributeType.GetConstructor(ctorParameters);
      attribute = new CustomAttributeBuilder(ctor,
         new object[] { "My Example Company" });
      myAssembly.SetCustomAttribute(attribute);

      // The AssemblyProductAttribute sets the Product Name item.
      //
      attributeType = typeof(AssemblyProductAttribute);
      ctor = attributeType.GetConstructor(ctorParameters);
      attribute = new CustomAttributeBuilder(ctor,
         new object[] { "My Product Name" });
      myAssembly.SetCustomAttribute(attribute);

      // Define the assembly's only module. For a single-file assembly,
      // the module name is the assembly name.
      //
      ModuleBuilder myModule =
         myAssembly.DefineDynamicModule(assemName.Name,
            assemName.Name + ".exe");

      // No types or methods are created for this example.

      // Define the unmanaged version information resource, which
      // contains the attribute informaion applied earlier, and save
      // the assembly. Use the Windows Explorer to examine the properties
      // of the .exe file.
      //
      myAssembly.DefineVersionInfoResource();
      myAssembly.Save(assemName.Name + ".exe");
   }
}
Imports System.Reflection
Imports System.Reflection.Emit

Module Example

   Sub Main()

      Dim assemName As New AssemblyName()
      assemName.Name = "EmittedAssembly"

      ' Create a dynamic assembly in the current application domain,
      ' specifying that the assembly is to be saved.
      '
      Dim myAssembly As AssemblyBuilder = _
         AppDomain.CurrentDomain.DefineDynamicAssembly(assemName, _
            AssemblyBuilderAccess.Save)


      ' To apply an attribute to a dynamic assembly, first get the 
      ' attribute type. The AssemblyFileVersionAttribute sets the 
      ' File Version field on the Version tab of the Windows file
      ' properties dialog.
      '
      Dim attributeType As Type = GetType(AssemblyFileVersionAttribute)

      ' To identify the constructor, use an array of types representing
      ' the constructor's parameter types. This ctor takes a string.
      '
      Dim ctorParameters() As Type = { GetType(String) }

      ' Get the constructor for the attribute.
      '
      Dim ctor As ConstructorInfo = _
                         attributeType.GetConstructor(ctorParameters)

      ' Pass the constructor and an array of arguments (in this case,
      ' an array containing a single string) to the 
      ' CustomAttributeBuilder constructor.
      '
      Dim ctorArgs() As Object = { "2.0.3033.0" }
      Dim attribute As New CustomAttributeBuilder(ctor, ctorArgs)

      ' Finally, apply the attribute to the assembly.
      '
      myAssembly.SetCustomAttribute(attribute)


      ' The pattern described above is used to create and apply
      ' several more attributes. As it happens, all these attributes
      ' have a constructor that takes a string, so the same ctorArgs
      ' variable works for all of them.
      

      ' The AssemblyTitleAttribute sets the Description field on
      ' the General tab and the Version tab of the Windows file 
      ' properties dialog.
      '
      attributeType = GetType(AssemblyTitleAttribute)
      ctor = attributeType.GetConstructor(ctorParameters)
      ctorArgs = New Object() { "The Application Title" }
      attribute = New CustomAttributeBuilder(ctor, ctorArgs)
      myAssembly.SetCustomAttribute(attribute)

      ' The AssemblyCopyrightAttribute sets the Copyright field on
      ' the Version tab.
      '
      attributeType = GetType(AssemblyCopyrightAttribute)
      ctor = attributeType.GetConstructor(ctorParameters)
      ctorArgs = New Object() { "© My Example Company 1991-2005" }
      attribute = New CustomAttributeBuilder(ctor, ctorArgs)
      myAssembly.SetCustomAttribute(attribute)

      ' The AssemblyDescriptionAttribute sets the Comment item.
      '
      attributeType = GetType(AssemblyDescriptionAttribute)
      ctor = attributeType.GetConstructor(ctorParameters)
      attribute = New CustomAttributeBuilder(ctor, _
         New Object() { "This is a comment." })
      myAssembly.SetCustomAttribute(attribute)

      ' The AssemblyCompanyAttribute sets the Company item.
      '
      attributeType = GetType(AssemblyCompanyAttribute)
      ctor = attributeType.GetConstructor(ctorParameters)
      attribute = New CustomAttributeBuilder(ctor, _
         New Object() { "My Example Company" })
      myAssembly.SetCustomAttribute(attribute)

      ' The AssemblyProductAttribute sets the Product Name item.
      '
      attributeType = GetType(AssemblyProductAttribute)
      ctor = attributeType.GetConstructor(ctorParameters)
      attribute = New CustomAttributeBuilder(ctor, _
         New Object() { "My Product Name" })
      myAssembly.SetCustomAttribute(attribute)


      ' Define the assembly's only module. For a single-file assembly,
      ' the module name is the assembly name.
      '
      Dim myModule As ModuleBuilder = _
         myAssembly.DefineDynamicModule(assemName.Name, _
            assemName.Name & ".exe")

      ' No types or methods are created for this example.


      ' Define the unmanaged version information resource, which
      ' contains the attribute informaion applied earlier, and save
      ' the assembly. Use the Windows Explorer to examine the properties
      ' of the .exe file.
      '
      myAssembly.DefineVersionInfoResource()
      myAssembly.Save(assemName.Name & ".exe")

   End Sub 
End Module

Konstruktorok

Name Description
AssemblyCompanyAttribute(String)

Inicializálja a AssemblyCompanyAttribute osztály új példányát.

Tulajdonságok

Name Description
Company

Lekéri a cégnév adatait.

TypeId

Ha származtatott osztályban implementálják, ehhez egy egyedi azonosítót Attributekap.

(Öröklődés forrása Attribute)

Metódusok

Name Description
Equals(Object)

Olyan értéket ad vissza, amely jelzi, hogy ez a példány egyenlő-e egy adott objektummal.

(Öröklődés forrása Attribute)
GetHashCode()

A példány kivonatkódját adja vissza.

(Öröklődés forrása Attribute)
GetType()

Lekéri az Type aktuális példányt.

(Öröklődés forrása Object)
IsDefaultAttribute()

Ha egy származtatott osztályban felül van bírálva, azt jelzi, hogy a példány értéke-e a származtatott osztály alapértelmezett értéke.

(Öröklődés forrása Attribute)
Match(Object)

Származtatott osztály felülírásakor egy olyan értéket ad vissza, amely jelzi, hogy ez a példány egy adott objektummal egyenlő-e.

(Öröklődés forrása Attribute)
MemberwiseClone()

Az aktuális Objectpéldány sekély másolatát hozza létre.

(Öröklődés forrása Object)
ToString()

Az aktuális objektumot jelképező sztringet ad vissza.

(Öröklődés forrása Object)

Explicit interfész-implementációk

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

Névkészletet képez le a küldési azonosítók megfelelő készletére.

(Öröklődés forrása Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Lekéri egy objektum típusadatait, amelyek a felület típusadatainak lekérésére használhatók.

(Öröklődés forrása Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Lekéri az objektumok által biztosított típusinformációs felületek számát (0 vagy 1).

(Öröklődés forrása Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Hozzáférést biztosít az objektumok által közzétett tulajdonságokhoz és metódusokhoz.

(Öröklődés forrása Attribute)

A következőre érvényes:

Lásd még