LicFileLicenseProvider Classe

Définition

Fournit une implémentation d’un LicenseProvider. Le fournisseur fonctionne de la même manière que le modèle de licence standard Microsoft .NET Framework.

public ref class LicFileLicenseProvider : System::ComponentModel::LicenseProvider
public class LicFileLicenseProvider : System.ComponentModel.LicenseProvider
type LicFileLicenseProvider = class
    inherit LicenseProvider
Public Class LicFileLicenseProvider
Inherits LicenseProvider
Héritage
LicFileLicenseProvider

Exemples

L’exemple suivant crée un contrôle sous licence à l’aide de la Validate méthode. Il utilise LicFileLicenseProvider pour le gestionnaire de licences.

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

Remarques

Les LicFileLicenseProvider offres GetLicense et IsKeyValid méthodes. La IsKeyValid méthode détermine si l’élément LicenseKey récupéré par la GetLicense méthode est valide. Lorsque vous héritez de cette classe, vous pouvez remplacer la IsKeyValid méthode pour fournir votre propre logique de validation.

Cette classe existe pour fournir des fonctionnalités de licence similaires aux licences COM et utilise des fichiers de licence texte.

Constructeurs

Nom Description
LicFileLicenseProvider()

Initialise une nouvelle instance de la classe LicFileLicenseProvider.

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)
GetKey(Type)

Retourne une clé pour le type spécifié.

GetLicense(LicenseContext, Type, Object, Boolean)

Retourne une licence pour l’instance du composant, si celle-ci est disponible.

GetType()

Obtient la Type de l’instance actuelle.

(Hérité de Object)
IsKeyValid(String, Type)

Détermine si la clé récupérée par la GetLicense(LicenseContext, Type, Object, Boolean) méthode est valide pour le type spécifié.

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)

S’applique à

Voir aussi