LicenseProvider Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Fournit la classe de base pour l’implémentation abstract d’un fournisseur de licences.
public ref class LicenseProvider abstract
public abstract class LicenseProvider
type LicenseProvider = class
Public MustInherit Class LicenseProvider
- Héritage
-
LicenseProvider
- Dérivé
Exemples
L’exemple de code suivant crée un contrôle sous licence à l’aide de la Validate méthode. Il utilise un LicenseProvider qui est implémenté par la LicFileLicenseProvider classe.
// Adds the LicenseProviderAttribute to the control.
[LicenseProvider(LicFileLicenseProvider::typeid)]
public ref class MyControl: public Control
{
// Creates a new, null license.
private:
License^ license;
public:
MyControl()
{
// Adds Validate to the control's constructor.
license = LicenseManager::Validate( MyControl::typeid, this );
// Insert code to perform other instance creation tasks here.
}
public:
~MyControl()
{
if ( license != nullptr )
{
delete license;
license = nullptr;
}
}
};
using System.ComponentModel;
using System.Windows.Forms;
// Adds the LicenseProviderAttribute to the control.
[LicenseProvider(typeof(LicFileLicenseProvider))]
public class MyControl : Control
{
// Creates a new, null license.
License license;
public MyControl()
{
// Adds Validate to the control's constructor.
license = LicenseManager.Validate(typeof(MyControl), this);
// Insert code to perform other instance creation tasks here.
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (license != null)
{
license.Dispose();
license = null;
}
}
}
}
Imports System.ComponentModel
Imports System.Windows.Forms
' Adds the LicenseProviderAttribute to the control.
<LicenseProvider(GetType(LicFileLicenseProvider))> _
Public Class MyControl
Inherits Control
' Creates a new, null license.
Private license As License = Nothing
Public Sub New()
' Adds Validate to the control's constructor.
license = LicenseManager.Validate(GetType(MyControl), Me)
' Insert code to perform other instance creation tasks here.
End Sub
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If (license IsNot Nothing) Then
license.Dispose()
license = Nothing
End If
End If
End Sub
End Class
Notes pour les responsables de l’implémentation
Lorsque vous héritez de LicenseProvider, vous devez remplacer la GetLicense(LicenseContext, Type, Object, Boolean) méthode.
Consultez LicFileLicenseProvider une implémentation de cette classe.
Constructeurs
| Nom | Description |
|---|---|
| LicenseProvider() |
Initialise une nouvelle instance de la classe LicenseProvider. |
Méthodes
| Nom | Description |
|---|---|
| Equals(Object) |
Détermine si l'objet spécifié est identique à l'objet actuel. (Hérité de Object) |
| GetHashCode() |
Sert de fonction de hachage par défaut. (Hérité de Object) |
| GetLicense(LicenseContext, Type, Object, Boolean) |
En cas de substitution dans une classe dérivée, obtient une licence pour une instance ou un type de composant, lorsqu’un contexte est donné et si le refus d’une licence lève une exception. |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |