LicenseProvider Klasa

Definicja

Udostępnia klasę bazową abstract do implementowania dostawcy licencji.

public ref class LicenseProvider abstract
public abstract class LicenseProvider
type LicenseProvider = class
Public MustInherit Class LicenseProvider
Dziedziczenie
LicenseProvider
Pochodne

Przykłady

Poniższy przykład kodu tworzy licencjonowany formant przy użyciu Validate metody . Używa klasy LicenseProvider , która jest implementowana przez klasę LicFileLicenseProvider .

// 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;
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.
   private License license = null;
 
   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

Uwagi dotyczące implementowania

Po dziedziczeniu po LicenseProvidermetodzie należy zastąpić metodę GetLicense(LicenseContext, Type, Object, Boolean) .

Zobacz LicFileLicenseProvider implementację tej klasy. Aby uzyskać więcej informacji na temat licencjonowania, zobacz Instrukcje: składniki licencji i kontrolki.

Konstruktory

LicenseProvider()

Inicjuje nowe wystąpienie klasy LicenseProvider.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetLicense(LicenseContext, Type, Object, Boolean)

W przypadku zastąpienia w klasie pochodnej otrzymuje licencję dla wystąpienia lub typu składnika, gdy dany kontekst i czy odmowa licencji zgłasza wyjątek.

GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też