LicenseProviderAttribute Osztály
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Megadja az LicenseProvider osztályhoz használni kívánt elemet. Ez az osztály nem örökölhető.
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
- Öröklődés
- Attribútumok
Példák
Az alábbi példakód a LicFileLicenseProvider licencszolgáltatót MyControlhasználja.
[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
A következő példakód létrehozza az osztály egy példányát MyControl . Ezután lekéri az osztály attribútumait, és kinyomtatja a licencszolgáltató által myNewControlhasznált nevét.
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();
// 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
Megjegyzések
Amikor létrehoz egy licencelendő összetevőt, meg kell adnia az LicenseProvider összetevőt egy LicenseProviderAttribute.
LicenseProvider A tulajdonság használatával lekérheti a TypeLicenseProvider .
Az attribútumokról további információt az Attribútumok című témakörben talál. A licenceléssel kapcsolatos további információkért lásd: Licencösszetevők és -vezérlők.
Note
Az HostProtectionAttribute osztályra alkalmazott attribútum a következő Resources tulajdonságértéket tartalmazza: SharedState. Ez HostProtectionAttribute nem érinti az asztali alkalmazásokat (amelyek általában egy ikonra duplán kattintva, egy parancs beírásával vagy egy URL-cím beírásával indulnak el a böngészőben). További információ: HostProtectionAttribute osztály vagy SQL Server Programozási és gazdagépvédelmi attribútumok.
Konstruktorok
| Name | Description |
|---|---|
| LicenseProviderAttribute() |
Inicializálja az LicenseProviderAttribute osztály új példányát licencszolgáltató nélkül. |
| LicenseProviderAttribute(String) |
Inicializálja az osztály új példányát LicenseProviderAttribute a megadott típussal. |
| LicenseProviderAttribute(Type) |
Inicializálja az osztály új példányát LicenseProviderAttribute a megadott licencszolgáltató típusával. |
Mezők
| Name | Description |
|---|---|
| Default |
Az alapértelmezett értéket adja meg, amely nem szolgáltató. Ez |
Tulajdonságok
| Name | Description |
|---|---|
| LicenseProvider |
Lekéri a társított osztályhoz használni kívánt licencszolgáltatót. |
| TypeId |
Az attribútumtípus egyedi azonosítóját jelzi. |
Metódusok
| Name | Description |
|---|---|
| Equals(Object) |
Azt jelzi, hogy ez a példány és egy megadott objektum egyenlő-e. |
| GetHashCode() |
A példány kivonatkódját adja vissza. |
| GetType() |
Lekéri az Type aktuális példányt. (Öröklődés forrása Object) |
| IsDefaultAttribute() |
Ha egy származtatott osztályban felül van bírálva, azt jelzi, hogy a példány értéke-e a származtatott osztály alapértelmezett értéke. (Öröklődés forrása Attribute) |
| Match(Object) |
Származtatott osztály felülírásakor egy olyan értéket ad vissza, amely jelzi, hogy ez a példány egy adott objektummal egyenlő-e. (Öröklődés forrása Attribute) |
| MemberwiseClone() |
Az aktuális Objectpéldány sekély másolatát hozza létre. (Öröklődés forrása Object) |
| ToString() |
Az aktuális objektumot jelképező sztringet ad vissza. (Öröklődés forrása Object) |
Explicit interfész-implementációk
| Name | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Névkészletet képez le a küldési azonosítók megfelelő készletére. (Öröklődés forrása Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Lekéri egy objektum típusadatait, amelyek a felület típusadatainak lekérésére használhatók. (Öröklődés forrása Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Lekéri az objektumok által biztosított típusinformációs felületek számát (0 vagy 1). (Öröklődés forrása Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Hozzáférést biztosít az objektumok által közzétett tulajdonságokhoz és metódusokhoz. (Öröklődés forrása Attribute) |