LicFileLicenseProvider Klass

Definition

Tillhandahåller en implementering av en LicenseProvider. Providern fungerar på ett liknande sätt som standardlicensmodellen 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
Arv
LicFileLicenseProvider

Exempel

I följande exempel skapas en licensierad kontroll med hjälp av Validate metoden . Den använder LicFileLicenseProvider för licenshanteraren.

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

Kommentarer

Erbjudandena LicFileLicenseProviderGetLicense och IsKeyValid metoderna. Metoden IsKeyValid avgör om den LicenseKey som hämtas av GetLicense metoden är giltig. När du ärver från den här klassen kan du åsidosätta IsKeyValid metoden för att ange din egen valideringslogik.

Den här klassen finns för att tillhandahålla liknande licensieringsfunktioner som COM-licensiering och använder textlicensfiler.

Mer information om licensiering finns i Så här: Licenskomponenter och kontroller.

Konstruktorer

Name Description
LicFileLicenseProvider()

Initierar en ny instans av LicFileLicenseProvider klassen.

Metoder

Name Description
Equals(Object)

Avgör om det angivna objektet är lika med det aktuella objektet.

(Ärvd från Object)
GetHashCode()

Fungerar som standard-hash-funktion.

(Ärvd från Object)
GetKey(Type)

Returnerar en nyckel för den angivna typen.

GetLicense(LicenseContext, Type, Object, Boolean)

Returnerar en licens för komponentens instans, om en är tillgänglig.

GetType()

Hämtar den aktuella instansen Type .

(Ärvd från Object)
IsKeyValid(String, Type)

Avgör om nyckeln som GetLicense(LicenseContext, Type, Object, Boolean) metoden hämtar är giltig för den angivna typen.

MemberwiseClone()

Skapar en ytlig kopia av den aktuella Object.

(Ärvd från Object)
ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)

Gäller för

Se även