LicFileLicenseProvider 类   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供 LicenseProvider 的实现。 提供程序与 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
		- 继承
 
示例
以下示例使用 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.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
	注解
套餐LicFileLicenseProviderGetLicense和IsKeyValid方法。 方法IsKeyValid确定 方法检索的 GetLicense 是否LicenseKey有效。 从此类继承时,可以重写 IsKeyValid 方法以提供自己的验证逻辑。
此类的存在旨在提供与 COM 许可类似的许可功能,并使用文本许可证文件。
有关许可的详细信息,请参阅 如何:许可组件和控制。
构造函数
| LicFileLicenseProvider() | 
		 初始化 LicFileLicenseProvider 类的新实例。  | 
        	
方法
| Equals(Object) | 
		 确定指定对象是否等于当前对象。 (继承自 Object) | 
        	
| GetHashCode() | 
		 作为默认哈希函数。 (继承自 Object) | 
        	
| GetKey(Type) | 
		 返回指定类型的密钥。  | 
        	
| GetLicense(LicenseContext, Type, Object, Boolean) | 
		 返回组件实例的许可证(如果有一个可用的话)。  | 
        	
| GetType() | 
		 获取当前实例的 Type。 (继承自 Object) | 
        	
| IsKeyValid(String, Type) | 
		 确定 GetLicense(LicenseContext, Type, Object, Boolean) 方法检索的密钥对指定的类型是否有效。  | 
        	
| MemberwiseClone() | 
		 创建当前 Object 的浅表副本。 (继承自 Object) | 
        	
| ToString() | 
		 返回表示当前对象的字符串。 (继承自 Object) |