LicenseProviderAttribute Classe

Definição

Especifica o LicenseProvider a usar 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 como o 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ça 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 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 = (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 marcando o componente com um LicenseProviderAttribute.

Use a LicenseProvider propriedade para obter o Type do LicenseProvider.

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. HostProtectionAttribute não afeta aplicativos de área de trabalho (que são normalmente iniciados com o clique duplo em um ícone, a digitação de um comando ou a inserção de uma URL em um navegador). Para obter mais informações, consulte a HostProtectionAttribute classe ou SQL Server Atributos de Programação e Proteção de Host.

Construtores

LicenseProviderAttribute()

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

LicenseProviderAttribute(String)

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

LicenseProviderAttribute(Type)

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

Campos

Default

Especifica o valor padrão, que é nenhum provedor. Esse campo static é somente leitura.

Propriedades

LicenseProvider

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

TypeId

Indica uma ID exclusiva para este tipo de atributo.

Métodos

Equals(Object)

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

GetHashCode()

Retorna o código hash para a 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 Object atual.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Implantações explícitas de interface

_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 para um objeto, que pode ser usado para obter as informações de tipo para 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