LicenseProviderAttribute Classe

Definição

Especifica o LicenseProvider que deve ser usado com uma classe. Esta 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 seguinte utiliza o LicFileLicenseProvider como fornecedor de licenças 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 exemplo de código seguinte cria uma instância da MyControl classe. Depois, obtém os atributos da classe e imprime o nome do fornecedor 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();

    // 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

Observações

Quando cria um componente que pretende licenciar, deve especificar o LicenseProvider marcando o componente com um LicenseProviderAttribute.

Use a LicenseProvider propriedade para obter o Type de .LicenseProvider

Para mais informações sobre atributos, consulte Atributos. Para mais informações sobre licenciamento, veja Como: Licenciar Componentes e Controlos.

Note

O HostProtectionAttribute atributo aplicado a esta classe tem o seguinte Resources valor de propriedade: SharedState. Isto HostProtectionAttribute não afeta aplicações de ambiente de trabalho (que normalmente são iniciadas com duplo clique num ícone, digitação de um comando ou introdução de um URL no navegador). Para mais informações, consulte a classe HostProtectionAttribute ou SQL Server Atributos de Programação e Proteção de Host.

Construtores

Name Description
LicenseProviderAttribute()

Inicializa uma nova instância da LicenseProviderAttribute classe sem um fornecedor 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 especificado de fornecedor de licença.

Campos

Name Description
Default

Especifica o valor padrão, que é sem fornecedor. Este static campo é só de leitura.

Propriedades

Name Description
LicenseProvider

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

TypeId

Indica um ID único para este tipo de atributo.

Métodos

Name Description
Equals(Object)

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

GetHashCode()

Devolve o código de hash para esta instância.

GetType()

Obtém o Type da instância atual.

(Herdado de Object)
IsDefaultAttribute()

Quando sobrescrito numa classe derivada, indica se o valor desta instância é o valor padrão para a classe derivada.

(Herdado de Attribute)
Match(Object)

Quando sobrescrito numa classe derivada, devolve um valor que indica se esta instância é igual a um objeto especificado.

(Herdado de Attribute)
MemberwiseClone()

Cria uma cópia superficial do atual Object.

(Herdado de Object)
ToString()

Devolve uma cadeia que representa o objeto atual.

(Herdado de Object)

Implementações de Interface Explícita

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

Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de despacho.

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

Recupera a informação de tipo de um objeto, que pode ser usada para obter a informação de tipo para uma interface.

(Herdado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

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

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

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

(Herdado de Attribute)

Aplica-se a

Ver também