LicenseProviderAttribute Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Especifica el LicenseProvider que se va a usar con una clase . Esta clase no puede heredarse.
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
- Herencia
- Atributos
Ejemplos
En el ejemplo de código siguiente se usa LicFileLicenseProvider como proveedor de licencias 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
En el ejemplo de código siguiente se crea una instancia de la MyControl clase . A continuación, obtiene los atributos de la clase e imprime el nombre del proveedor de licencias 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
Comentarios
Al crear un componente que quiera conceder, debe especificar LicenseProvider el marcando el componente con un LicenseProviderAttribute.
Utilice la LicenseProvider propiedad para obtener el Type de .LicenseProvider
Para obtener más información sobre los atributos, vea Atributos. Para obtener más información sobre las licencias, vea Cómo: Licencias de componentes y controles.
Nota:
El HostProtectionAttribute atributo aplicado a esta clase tiene el siguiente Resources valor de propiedad: SharedState. No HostProtectionAttribute afecta a las aplicaciones de escritorio (que normalmente se inician haciendo doble clic en un icono, escribiendo un comando o escribiendo una dirección URL en un explorador). Para obtener más información, consulte la clase o los HostProtectionAttributeatributos de programación y protección de host de SQL Server.
Constructores
| Nombre | Description |
|---|---|
| LicenseProviderAttribute() |
Inicializa una nueva instancia de la LicenseProviderAttribute clase sin un proveedor de licencias. |
| LicenseProviderAttribute(String) |
Inicializa una nueva instancia de la LicenseProviderAttribute clase con el tipo especificado. |
| LicenseProviderAttribute(Type) |
Inicializa una nueva instancia de la LicenseProviderAttribute clase con el tipo de proveedor de licencias especificado. |
Campos
| Nombre | Description |
|---|---|
| Default |
Especifica el valor predeterminado, que no es ningún proveedor. Este |
Propiedades
| Nombre | Description |
|---|---|
| LicenseProvider |
Obtiene el proveedor de licencias que se debe usar con la clase asociada. |
| TypeId |
Indica un identificador único para este tipo de atributo. |
Métodos
| Nombre | Description |
|---|---|
| Equals(Object) |
Indica si esta instancia y un objeto especificado son iguales. |
| GetHashCode() |
Devuelve el código hash de esta instancia. |
| GetType() |
Obtiene el Type de la instancia actual. (Heredado de Object) |
| IsDefaultAttribute() |
Cuando se reemplaza en una clase derivada, indica si el valor de esta instancia es el valor predeterminado de la clase derivada. (Heredado de Attribute) |
| Match(Object) |
Cuando se reemplaza en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado. (Heredado de Attribute) |
| MemberwiseClone() |
Crea una copia superficial del Objectactual. (Heredado de Object) |
| ToString() |
Devuelve una cadena que representa el objeto actual. (Heredado de Object) |
Implementaciones de interfaz explícitas
| Nombre | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío. (Heredado de Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera la información de tipo de un objeto, que se puede usar para obtener la información de tipo de una interfaz. (Heredado de Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1). (Heredado de Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Proporciona acceso a propiedades y métodos expuestos por un objeto . (Heredado de Attribute) |