LicenseProviderAttribute Klasa

Definicja

Określa LicenseProvider , który ma być używany z klasą. Klasa ta nie może być dziedziczona.

public ref class LicenseProviderAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)]
public sealed class LicenseProviderAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)>]
type LicenseProviderAttribute = class
    inherit Attribute
Public NotInheritable Class LicenseProviderAttribute
Inherits Attribute
Dziedziczenie
LicenseProviderAttribute
Atrybuty

Przykłady

Poniższy przykład kodu używa jako LicFileLicenseProvider dostawcy licencji dla MyControlprogramu .

[LicenseProvider(LicFileLicenseProvider::typeid)]
ref class MyControl: public Control
{
protected:

   // Insert code here.
   ~MyControl()
   {
      /* All components must dispose of the licenses they grant. 
               * Insert code here to dispose of the license. */
   }
};
[LicenseProvider(typeof(LicFileLicenseProvider))]
 public class MyControl : Control {
 
    // Insert code here.
 
    protected override void Dispose(bool disposing) {
       /* All components must dispose of the licenses they grant. 
        * Insert code here to dispose of the license. */
    }
 }
<LicenseProvider(GetType(LicFileLicenseProvider))> _
Public Class MyControl
    Inherits Control
    
    ' Insert code here.
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        ' All components must dispose of the licenses they grant.
        ' Insert code here to dispose of the license.
    End Sub        

End Class

Następny przykład kodu tworzy wystąpienie MyControl klasy. Następnie pobiera atrybuty klasy i wyświetla nazwę dostawcy licencji używanego przez myNewControlprogram .

int main()
{
   // Creates a new component.
   MyControl^ myNewControl = gcnew MyControl;

   // Gets the attributes for the component.
   AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewControl );

   /* Prints the name of the license provider by retrieving the LicenseProviderAttribute 
        * from the AttributeCollection. */
   LicenseProviderAttribute^ myAttribute = dynamic_cast<LicenseProviderAttribute^>(attributes[ LicenseProviderAttribute::typeid ]);
   Console::WriteLine( "The license provider for this class is: {0}", myAttribute->LicenseProvider );
   return 0;
}
public static int Main() {
    // Creates a new component.
    MyControl myNewControl = new MyControl();
 
    // Gets the attributes for the component.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewControl);
 
    /* Prints the name of the license provider by retrieving the LicenseProviderAttribute 
     * from the AttributeCollection. */
    LicenseProviderAttribute myAttribute = (LicenseProviderAttribute)attributes[typeof(LicenseProviderAttribute)];
    Console.WriteLine("The license provider for this class is: " + myAttribute.LicenseProvider.ToString());
 
    return 0;
 }
Public Shared Function Main() As Integer
    ' Creates a new component.
    Dim myNewControl As New MyControl()
    
    ' Gets the attributes for the component.
    Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewControl)
    
    ' Prints the name of the license provider by retrieving the LicenseProviderAttribute 
    ' from the AttributeCollection. 
    Dim myAttribute As LicenseProviderAttribute = _
        CType(attributes(GetType(LicenseProviderAttribute)), LicenseProviderAttribute)
        
    Console.WriteLine(("The license provider for this class is: " & _
        myAttribute.LicenseProvider.ToString()))
    Return 0
End Function

Uwagi

Podczas tworzenia składnika, który chcesz licencjonować, musisz określić LicenseProvider element, oznaczając składnik za pomocą elementu LicenseProviderAttribute.

Użyj właściwości , LicenseProvider aby pobrać Type element LicenseProvider.

Aby uzyskać więcej informacji na temat atrybutów, zobacz Atrybuty. Aby uzyskać więcej informacji na temat licencjonowania, zobacz Instrukcje: składniki licencji i kontrolki.

Uwaga

Atrybut HostProtectionAttribute zastosowany do tej klasy ma następującą Resources wartość właściwości: SharedState. Atrybut HostProtectionAttribute nie ma wpływu na aplikacje pulpitu (które typowo są uruchamiane przez dwukrotne kliknięcie ikony, wpisanie polecenia albo wprowadzenie adresu URL w przeglądarce). Aby uzyskać więcej informacji, zobacz klasę HostProtectionAttribute lub SQL Server Programowanie i atrybuty ochrony hosta.

Konstruktory

LicenseProviderAttribute()

Inicjuje LicenseProviderAttribute nowe wystąpienie klasy bez dostawcy licencji.

LicenseProviderAttribute(String)

Inicjuje LicenseProviderAttribute nowe wystąpienie klasy o określonym typie.

LicenseProviderAttribute(Type)

Inicjuje LicenseProviderAttribute nowe wystąpienie klasy z określonym typem dostawcy licencji.

Pola

Default

Określa wartość domyślną, która nie jest dostawcą. To static pole jest tylko do odczytu.

Właściwości

LicenseProvider

Pobiera dostawcę licencji, który musi być używany z skojarzoną klasą.

TypeId

Wskazuje unikatowy identyfikator tego typu atrybutu.

Metody

Equals(Object)

Wskazuje, czy to wystąpienie oraz określony obiekt są równe.

GetHashCode()

Zwraca wartość skrótu dla tego wystąpienia.

GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
IsDefaultAttribute()

W przypadku zastąpienia w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną klasy pochodnej.

(Odziedziczone po Attribute)
Match(Object)

Po przesłonięciu w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Pobiera informacje o typie dla obiektu, który może służyć do pobierania informacji o typie dla interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy

Zobacz też