LicFileLicenseProvider 類別

定義

提供 LicenseProvider 的實作。 提供者 (Provider) 運作的方式與 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
繼承
LicFileLicenseProvider

範例

下列範例會使用 Validate 方法建立授權控件。 它會針對授權管理員使用 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

備註

GetLicense供應LicFileLicenseProvider專案和IsKeyValid方法。 方法IsKeyValid會判斷 方法所擷取的 GetLicense 是否LicenseKey有效。 當您繼承自這個類別時,可以覆寫 IsKeyValid 方法來提供您自己的驗證邏輯。

這個類別存在,可為 COM 授權提供類似的授權功能,並使用文字授權檔案。

如需授權的詳細資訊,請參閱 如何:授權元件和控件

建構函式

LicFileLicenseProvider()

初始化 LicFileLicenseProvider 類別的新執行個體。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetKey(Type)

傳回指定型別的索引鍵。

GetLicense(LicenseContext, Type, Object, Boolean)

傳回元件的執行個體 (Instance) 授權 (如果有的話)。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IsKeyValid(String, Type)

判斷 GetLicense(LicenseContext, Type, Object, Boolean) 方法所擷取的索引鍵對指定型別是否有效。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱