LicenseManager クラス

定義

コンポーネントにライセンスを追加し、LicenseProvider を管理するためのプロパティとメソッドを提供します。 このクラスは継承できません。

public ref class LicenseManager sealed
public sealed class LicenseManager
type LicenseManager = class
Public NotInheritable Class LicenseManager
継承
LicenseManager

次のコード例では、メソッドを使用してライセンスされたコントロールを Validate 作成します。 クラスによって実装される a LicenseProviderLicFileLicenseProvider 使用します。

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

注釈

このクラスはLicenseManager、次staticのプロパティをUsageMode提供します。 CurrentContext クラスには、次staticのメソッドも用意されています。 IsValidCreateWithContextValidate

ライセンスを付与するコンポーネントを作成する場合は、次の操作を行う必要があります。

  1. LicenseProviderを使用してコンポーネントLicenseProviderAttributeをマークして指定します。

  2. コンポーネントのコンストラクターで、またはIsValid呼び出Validateします。 Validate は、 LicenseException 有効なライセンスなしでインスタンスを作成しようとしたときに a をスローします。 IsValid は例外をスローしません。

  3. コンポーネントが破棄または最終処理されたときに付与されるすべてのライセンスを呼び出 Dispose します。

ライセンスの詳細については、「 方法: ライセンス コンポーネントとコントロール」を参照してください。

プロパティ

CurrentContext

ライセンス付きのオブジェクトをいつ使用できるかを指定する現在の LicenseContext を取得または設定します。

UsageMode

LicenseUsageMode においてライセンス付きのオブジェクトをいつ使用できるかを指定する CurrentContext を取得します。

メソッド

CreateWithContext(Type, LicenseContext)

ライセンス付きのインスタンスを使用できるコンテキストを指定して、指定した型のインスタンスを作成します。

CreateWithContext(Type, LicenseContext, Object[])

引数と、ライセンス付きのインスタンスを使用できるコンテキストを指定して、指定した型のインスタンスを作成します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsLicensed(Type)

指定した型が有効なライセンスを与えられているかどうかを示す値を返します。

IsValid(Type)

指定した型に有効なライセンスを与えることができるかどうかを判断します。

IsValid(Type, Object, License)

型の指定したインスタンスに対して、有効なライセンスを与えることができるかどうかを判断します。 このメソッドは、有効な License を作成します。

LockContext(Object)

指定したオブジェクトの現在の LicenseContext を変更できないようにします。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
UnlockContext(Object)

指定したオブジェクトの現在の LicenseContext を変更できるようにします。

Validate(Type)

指定した型にライセンスを与えることができるかどうかを判断します。

Validate(Type, Object)

指定した型のインスタンスに対して、ライセンスを与えることができるかどうかを判断します。

適用対象

こちらもご覧ください