Compartilhar via


LicenseProviderAttribute Classe

Definição

Especifica o LicenseProvider a ser usado com uma classe. Essa classe não pode ser herdada.

public ref class LicenseProviderAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)]
public sealed class LicenseProviderAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)>]
type LicenseProviderAttribute = class
    inherit Attribute
Public NotInheritable Class LicenseProviderAttribute
Inherits Attribute
Herança
LicenseProviderAttribute
Atributos

Exemplos

O exemplo de código a seguir usa o LicFileLicenseProvider provedor de licença para MyControl.

[LicenseProvider(LicFileLicenseProvider::typeid)]
ref class MyControl: public Control
{
protected:

   // Insert code here.
   ~MyControl()
   {
      /* All components must dispose of the licenses they grant. 
               * Insert code here to dispose of the license. */
   }
};
[LicenseProvider(typeof(LicFileLicenseProvider))]
public class MyControl : Control
{
    // Insert code here.

    protected override void Dispose(bool disposing)
    {
        /* All components must dispose of the licenses they grant. 
         * Insert code here to dispose of the license. */
    }
}
<LicenseProvider(GetType(LicFileLicenseProvider))> _
Public Class MyControl
    Inherits Control
    
    ' Insert code here.
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        ' All components must dispose of the licenses they grant.
        ' Insert code here to dispose of the license.
    End Sub        

End Class

O próximo exemplo de código cria uma instância da MyControl classe. Em seguida, ele obtém os atributos da classe e imprime o nome do provedor de licenças usado por myNewControl.

int main()
{
   // Creates a new component.
   MyControl^ myNewControl = gcnew MyControl;

   // Gets the attributes for the component.
   AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewControl );

   /* Prints the name of the license provider by retrieving the LicenseProviderAttribute 
        * from the AttributeCollection. */
   LicenseProviderAttribute^ myAttribute = dynamic_cast<LicenseProviderAttribute^>(attributes[ LicenseProviderAttribute::typeid ]);
   Console::WriteLine( "The license provider for this class is: {0}", myAttribute->LicenseProvider );
   return 0;
}
public static int Main()
{
    // Creates a new component.
    MyControl myNewControl = new();

    // Gets the attributes for the component.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewControl);

    /* Prints the name of the license provider by retrieving the LicenseProviderAttribute 
     * from the AttributeCollection. */
    LicenseProviderAttribute myAttribute = (LicenseProviderAttribute)attributes[typeof(LicenseProviderAttribute)];
    Console.WriteLine("The license provider for this class is: " + myAttribute.LicenseProvider.ToString());

    return 0;
}
Public Shared Function Main() As Integer
    ' Creates a new component.
    Dim myNewControl As New MyControl()
    
    ' Gets the attributes for the component.
    Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewControl)
    
    ' Prints the name of the license provider by retrieving the LicenseProviderAttribute 
    ' from the AttributeCollection. 
    Dim myAttribute As LicenseProviderAttribute = _
        CType(attributes(GetType(LicenseProviderAttribute)), LicenseProviderAttribute)
        
    Console.WriteLine(("The license provider for this class is: " & _
        myAttribute.LicenseProvider.ToString()))
    Return 0
End Function

Comentários

Ao criar um componente que deseja licenciar, você deve especificar o LicenseProvider componente marcando o componente com um LicenseProviderAttribute.

Use a LicenseProvider propriedade para obter o TypeLicenseProvider.

Para obter mais informações sobre atributos, consulte Atributos. Para obter mais informações sobre licenciamento, consulte Como licenciar componentes e controles.

Observação

O HostProtectionAttribute atributo aplicado a essa classe tem o seguinte Resources valor de propriedade: SharedState. Isso HostProtectionAttribute não afeta aplicativos da área de trabalho (que normalmente são iniciados clicando duas vezes em um ícone, digitando um comando ou inserindo uma URL em um navegador). Para obter mais informações, consulte a HostProtectionAttribute classe ou os atributos de programação e proteção de host do SQL Server.

Construtores

Nome Description
LicenseProviderAttribute()

Inicializa uma nova instância da LicenseProviderAttribute classe sem um provedor de licença.

LicenseProviderAttribute(String)

Inicializa uma nova instância da LicenseProviderAttribute classe com o tipo especificado.

LicenseProviderAttribute(Type)

Inicializa uma nova instância da LicenseProviderAttribute classe com o tipo de provedor de licença especificado.

Campos

Nome Description
Default

Especifica o valor padrão, que não é um provedor. Este static campo é somente leitura.

Propriedades

Nome Description
LicenseProvider

Obtém o provedor de licença que deve ser usado com a classe associada.

TypeId

Indica uma ID exclusiva para esse tipo de atributo.

Métodos

Nome Description
Equals(Object)

Indica se essa instância e um objeto especificado são iguais.

GetHashCode()

Retorna o código hash dessa instância.

GetType()

Obtém o Type da instância atual.

(Herdado de Object)
IsDefaultAttribute()

Quando substituído em uma classe derivada, indica se o valor dessa instância é o valor padrão para a classe derivada.

(Herdado de Attribute)
Match(Object)

Quando substituído em uma classe derivada, retorna um valor que indica se essa instância é igual a um objeto especificado.

(Herdado de Attribute)
MemberwiseClone()

Cria uma cópia superficial do Objectatual.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Implantações explícitas de interface

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

Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de expedição.

(Herdado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera as informações de tipo de um objeto, que podem ser usadas para obter as informações de tipo de uma interface.

(Herdado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Retorna o número de interfaces de informações do tipo que um objeto fornece (0 ou 1).

(Herdado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornece acesso a propriedades e métodos expostos por um objeto.

(Herdado de Attribute)

Aplica-se a

Confira também