LicFileLicenseProvider 类

定义

提供 LicenseProvider 的实现。Provides an implementation of a LicenseProvider. 提供程序与 Microsoft .NET Framework 标准授权模型的工作方式相似。The provider works in a similar fashion to the Microsoft .NET Framework standard licensing model.

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方法创建授权控件。The following example creates a licensed control using the Validate method. LicFileLicenseProvider它用于许可证管理器。It uses LicFileLicenseProvider for the license manager.

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

注解

LicFileLicenseProvider 提供GetLicense和方法IsKeyValidThe LicFileLicenseProvider offers GetLicense and IsKeyValid methods. 方法确定LicenseKeyGetLicense方法检索到的是否有效。 IsKeyValidThe IsKeyValid method determines whether the LicenseKey retrieved by the GetLicense method is valid. 从此类继承时, 可以重写IsKeyValid方法以提供您自己的验证逻辑。When you inherit from this class, you can override the IsKeyValid method to provide your own validation logic.

此类用于向 COM 授权提供类似的授权功能, 并使用文本许可证文件。This class exists to provide similar licensing functionality to COM licensing and uses text license files.

有关授权的详细信息, 请参阅如何:许可证组件和控件For more information on licensing, see How to: License Components and Controls.

构造函数

LicFileLicenseProvider()

初始化 LicFileLicenseProvider 类的新实例。Initializes a new instance of the LicFileLicenseProvider class.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetKey(Type)

返回指定类型的密钥。Returns a key for the specified type.

GetLicense(LicenseContext, Type, Object, Boolean)

返回组件实例的许可证(如果有一个可用的话)。Returns a license for the instance of the component, if one is available.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsKeyValid(String, Type)

确定 GetLicense(LicenseContext, Type, Object, Boolean) 方法检索的密钥对指定的类型是否有效。Determines whether the key that the GetLicense(LicenseContext, Type, Object, Boolean) method retrieves is valid for the specified type.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅