Share via


LicFileLicenseProvider Kelas

Definisi

Menyediakan implementasi dari LicenseProvider. Penyedia bekerja dengan cara yang sama dengan model lisensi standar 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
Warisan
LicFileLicenseProvider

Contoh

Contoh berikut membuat kontrol berlisensi menggunakan Validate metode . Ini menggunakan LicFileLicenseProvider untuk manajer lisensi.

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

Keterangan

Penawaran LicFileLicenseProviderGetLicense dan IsKeyValid metode. Metode IsKeyValid menentukan apakah metode yang LicenseKey diambil valid GetLicense . Ketika Anda mewarisi dari kelas ini, Anda dapat mengambil IsKeyValid alih metode untuk memberikan logika validasi Anda sendiri.

Kelas ini ada untuk menyediakan fungsionalitas lisensi serupa dengan lisensi COM dan menggunakan file lisensi teks.

Untuk informasi selengkapnya tentang lisensi, lihat Cara: Komponen dan Kontrol Lisensi.

Konstruktor

LicFileLicenseProvider()

Menginisialisasi instans baru kelas LicFileLicenseProvider.

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetKey(Type)

Mengembalikan kunci untuk jenis yang ditentukan.

GetLicense(LicenseContext, Type, Object, Boolean)

Mengembalikan lisensi untuk instans komponen, jika tersedia.

GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
IsKeyValid(String, Type)

Menentukan apakah kunci yang GetLicense(LicenseContext, Type, Object, Boolean) diambil metode valid untuk jenis yang ditentukan.

MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Lihat juga