LicenseProvider 类

定义

提供 abstract 基类以便实现许可证提供程序。Provides the abstract base class for implementing a license provider.

public ref class LicenseProvider abstract
public abstract class LicenseProvider
type LicenseProvider = class
Public MustInherit Class LicenseProvider
继承
LicenseProvider
派生

示例

下面的代码示例使用Validate方法创建授权控件。The following code example creates a licensed control using the Validate method. 它使用LicenseProvider LicFileLicenseProvider由类实现的。It uses a LicenseProvider that is implemented by the LicFileLicenseProvider class.

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

实施者说明

当从LicenseProvider继承时, 必须GetLicense(LicenseContext, Type, Object, Boolean)重写方法。When you inherit from LicenseProvider, you must override the GetLicense(LicenseContext, Type, Object, Boolean) method.

有关LicFileLicenseProvider此类的实现, 请参阅。See LicFileLicenseProvider for an implementation of this class. 有关授权的详细信息, 请参阅如何:许可证组件和控件For more information on licensing, see How to: License Components and Controls.

构造函数

LicenseProvider()

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

方法

Equals(Object)

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

(继承自 Object)
GetHashCode()

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

(继承自 Object)
GetLicense(LicenseContext, Type, Object, Boolean)

当在派生类中被重写时,获取组件的实例或类型的许可证(如果已给定上下文并确定拒绝许可证是否引发异常)。When overridden in a derived class, gets a license for an instance or type of component, when given a context and whether the denial of a license throws an exception.

GetType()

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

(继承自 Object)
MemberwiseClone()

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

(继承自 Object)
ToString()

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

(继承自 Object)

适用于

另请参阅