LicenseManager Klasse
Definition
Stellt Eigenschaften und Methoden bereit, um einer Komponente eine Lizenz hinzuzufügen und eine LicenseProvider-Klasse zu verwalten.Provides properties and methods to add a license to a component and to manage a LicenseProvider. Diese Klasse kann nicht vererbt werden.This class cannot be inherited.
public ref class LicenseManager sealed
public sealed class LicenseManager
type LicenseManager = class
Public NotInheritable Class LicenseManager
- Vererbung
-
LicenseManager
Beispiele
Im folgenden Codebeispiel wird mithilfe der Validate -Methode ein lizenziertes Steuerelement erstellt.The following code example creates a licensed control using the Validate method. Es verwendet einen LicenseProvider , der von der LicFileLicenseProvider -Klasse implementiert wird.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
Hinweise
Die LicenseManager -Klasse stellt die static
folgenden Eigenschaften CurrentContext bereit UsageMode: und.The LicenseManager class provides the following static
properties: CurrentContext and UsageMode. Die-Klasse stellt außerdem die static
folgenden Methoden CreateWithContextbereit IsValid:, Validateund.The class also provides the following static
methods: CreateWithContext, IsValid, and Validate.
Wenn Sie eine Komponente erstellen, die Sie lizenzieren möchten, müssen Sie die folgenden Schritte ausführen:When you create a component that you want to license, you must do the following:
Geben Sie LicenseProviderAttributean, indem Sie die Komponente mit einem markieren. LicenseProviderSpecify the LicenseProvider by marking the component with a LicenseProviderAttribute.
Ruft Validate oderIsValid im Konstruktor der Komponente auf.Call Validate or IsValid in the constructor of the component. Validatelöst eine LicenseException aus, wenn versucht wird, eine Instanz ohne gültige Lizenz zu erstellen.Validate throws a LicenseException when it tries to create an instance without a valid license. IsValidlöst keine Ausnahme aus.IsValid does not throw an exception.
Ruft Dispose für jede Lizenz auf, die gewährt wird, wenn die Komponente verworfen oder fertiggestellt wird.Call Dispose on any license that is granted when the component is disposed or finalized.
Weitere Informationen zur Lizenzierung finden Sie unter Gewusst wie: Lizenz Komponenten und-Steuerelemente.For more information on licensing, see How to: License Components and Controls.
Eigenschaften
CurrentContext |
Ruft die aktuelle LicenseContext-Klasse ab, die angibt, wann Sie das lizenzierte Objekt verwenden können, oder legt diese fest.Gets or sets the current LicenseContext, which specifies when you can use the licensed object. |
UsageMode |
Ruft die LicenseUsageMode-Enumeration ab, die angibt, wann Sie das lizenzierte Objekt für die CurrentContext-Eigenschaft verwenden können.Gets the LicenseUsageMode which specifies when you can use the licensed object for the CurrentContext. |
Methoden
CreateWithContext(Type, LicenseContext) |
Erstellt eine Instanz des angegebenen Typs, wenn ein Kontext angegeben ist, in dem Sie die lizenzierte Instanz verwenden können.Creates an instance of the specified type, given a context in which you can use the licensed instance. |
CreateWithContext(Type, LicenseContext, Object[]) |
Erstellt eine Instanz des angegebenen Typs mit den angegebenen Argumenten, wenn ein Kontext vorhanden ist, in dem Sie die lizenzierte Instanz verwenden können.Creates an instance of the specified type with the specified arguments, given a context in which you can use the licensed instance. |
Equals(Object) |
Ermittelt, ob das angegebene Objekt und das aktuelle Objekt gleich sind.Determines whether the specified object is equal to the current object. (Geerbt von Object) |
GetHashCode() |
Dient als die Standard-HashfunktionServes as the default hash function. (Geerbt von Object) |
GetType() |
Ruft den Type der aktuellen Instanz ab.Gets the Type of the current instance. (Geerbt von Object) |
IsLicensed(Type) |
Gibt zurück, ob der angegebene Typ über eine gültige Lizenz verfügt.Returns whether the given type has a valid license. |
IsValid(Type) |
Bestimmt, ob für den angegebenen Typ eine gültige Lizenz erteilt werden kann.Determines whether a valid license can be granted for the specified type. |
IsValid(Type, Object, License) |
Bestimmt, ob für die angegebene Instanz des Typs eine gültige Lizenz erteilt werden kann.Determines whether a valid license can be granted for the specified instance of the type. Diese Methode erstellt eine gültige License-Klasse.This method creates a valid License. |
LockContext(Object) |
Verhindert Änderungen an der aktuellen LicenseContext-Klasse des angegebenen Objekts.Prevents changes being made to the current LicenseContext of the given object. |
MemberwiseClone() |
Erstellt eine flache Kopie des aktuellen Object.Creates a shallow copy of the current Object. (Geerbt von Object) |
ToString() |
Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.Returns a string that represents the current object. (Geerbt von Object) |
UnlockContext(Object) |
Ermöglicht Änderungen an der aktuellen LicenseContext-Klasse des angegebenen Objekts.Allows changes to be made to the current LicenseContext of the given object. |
Validate(Type) |
Bestimmt, ob für den angegebenen Typ eine Lizenz erteilt werden kann.Determines whether a license can be granted for the specified type. |
Validate(Type, Object) |
Bestimmt, ob für die Instanz des angegebenen Typs eine Lizenz erteilt werden kann.Determines whether a license can be granted for the instance of the specified type. |