LicenseProviderAttribute Třída
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Určuje LicenseProvider, který se má použít s třídou. Tuto třídu nelze zdědit.
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
- Dědičnost
- Atributy
Příklady
Následující příklad kódu používá LicFileLicenseProvider jako poskytovatele licence pro MyControl.
[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
Další příklad kódu vytvoří instanci MyControl třídy. Potom získá atributy pro třídu a vytiskne název poskytovatele licencí, který myNewControlpoužívá .
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
Poznámky
Při vytváření součásti, kterou chcete licenci, je nutné určit LicenseProvider označením součásti pomocí znaku LicenseProviderAttribute.
LicenseProvider Vlastnost použijte k získání Type objektu LicenseProvider.
Další informace o atributech naleznete v tématu Atributy. Další informace o licencování naleznete v tématu Postupy: Součásti licencí a ovládací prvky.
Poznámka:
Atribut HostProtectionAttribute použitý pro tuto třídu má následující Resources hodnotu vlastnosti: SharedState. Nemá HostProtectionAttribute vliv na desktopové aplikace (které se obvykle spouští poklikáním na ikonu, zadáním příkazu nebo zadáním adresy URL v prohlížeči). Další informace naleznete v HostProtectionAttribute tématu třídy nebo programování SYSTÉMU SQL Server a atributy ochrany hostitele.
Konstruktory
| Name | Description |
|---|---|
| LicenseProviderAttribute() |
Inicializuje novou instanci LicenseProviderAttribute třídy bez poskytovatele licencí. |
| LicenseProviderAttribute(String) |
Inicializuje novou instanci LicenseProviderAttribute třídy se zadaným typem. |
| LicenseProviderAttribute(Type) |
Inicializuje novou instanci LicenseProviderAttribute třídy se zadaným typem poskytovatele licence. |
Pole
| Name | Description |
|---|---|
| Default |
Určuje výchozí hodnotu, která není zprostředkovatelem. Toto |
Vlastnosti
| Name | Description |
|---|---|
| LicenseProvider |
Získá poskytovatele licencí, který musí být použit s přidruženou třídou. |
| TypeId |
Označuje jedinečné ID pro tento typ atributu. |
Metody
| Name | Description |
|---|---|
| Equals(Object) |
Určuje, zda tato instance a zadaný objekt jsou rovny. |
| GetHashCode() |
Vrátí kód hash pro tuto instanci. |
| GetType() |
Získá Type aktuální instance. (Zděděno od Object) |
| IsDefaultAttribute() |
Při přepsání v odvozené třídě určuje, zda hodnota této instance je výchozí hodnotou pro odvozenou třídu. (Zděděno od Attribute) |
| Match(Object) |
Při přepsání v odvozené třídě vrátí hodnotu, která určuje, zda se tato instance rovná zadanému objektu. (Zděděno od Attribute) |
| MemberwiseClone() |
Vytvoří mělkou kopii aktuálního Object. (Zděděno od Object) |
| ToString() |
Vrátí řetězec, který představuje aktuální objekt. (Zděděno od Object) |
Explicitní implementace rozhraní
| Name | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Mapuje sadu názvů na odpovídající sadu identifikátorů pro rozesílání. (Zděděno od Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Načte informace o typu objektu, který lze použít k získání informací o typu pro rozhraní. (Zděděno od Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Získá počet rozhraní typu informací, které objekt poskytuje (0 nebo 1). (Zděděno od Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Poskytuje přístup k vlastnostem a metodám vystaveným objektem. (Zděděno od Attribute) |