LicenseProviderAttribute Класс
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Указывает LicenseProvider для использования с классом. Этот класс не может быть унаследован.
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
- Наследование
- Атрибуты
Примеры
В следующем примере кода в качестве поставщика лицензий используется LicFileLicenseProviderMyControlследующий пример кода.
[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
Следующий пример кода создает экземпляр MyControl класса. Затем он получает атрибуты для класса и выводит имя поставщика лицензий, используемого myNewControl.
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
Комментарии
При создании компонента, который требуется лицензировать, необходимо указать LicenseProvider его, помечая компонент с помощью .LicenseProviderAttribute
LicenseProvider Используйте свойство для получения TypeLicenseProviderобъекта .
Дополнительные сведения об атрибутах см. в разделе "Атрибуты". Дополнительные сведения о лицензировании см. в статье "Практическое руководство. Компоненты лицензии и элементы управления".
Замечание
Атрибут, применяемый к этому классу, имеет следующее HostProtectionAttributeResources значение свойства: SharedState Это HostProtectionAttribute не влияет на классические приложения (которые обычно запускаются путем двойного щелчка значка, ввода команды или ввода URL-адреса в браузере). Дополнительные сведения см. в HostProtectionAttribute разделе "Класс" или "Атрибуты защиты узлов SQL Server".
Конструкторы
| Имя | Описание |
|---|---|
| LicenseProviderAttribute() |
Инициализирует новый экземпляр LicenseProviderAttribute класса без поставщика лицензий. |
| LicenseProviderAttribute(String) |
Инициализирует новый экземпляр LicenseProviderAttribute класса с указанным типом. |
| LicenseProviderAttribute(Type) |
Инициализирует новый экземпляр LicenseProviderAttribute класса с указанным типом поставщика лицензий. |
Поля
| Имя | Описание |
|---|---|
| Default |
Указывает значение по умолчанию, которое не является поставщиком. Это |
Свойства
| Имя | Описание |
|---|---|
| LicenseProvider |
Возвращает поставщик лицензий, который должен использоваться с соответствующим классом. |
| TypeId |
Указывает уникальный идентификатор для этого типа атрибута. |
Методы
| Имя | Описание |
|---|---|
| Equals(Object) |
Указывает, равны ли этот экземпляр и указанный объект. |
| GetHashCode() |
Возвращает хэш-код для этого экземпляра. |
| GetType() |
Возвращает Type текущего экземпляра. (Унаследовано от Object) |
| IsDefaultAttribute() |
При переопределении в производном классе указывает, является ли значение этого экземпляра значением по умолчанию для производного класса. (Унаследовано от Attribute) |
| Match(Object) |
При переопределении в производном классе возвращает значение, указывающее, равен ли этот экземпляр указанному объекту. (Унаследовано от Attribute) |
| MemberwiseClone() |
Создает неглубокую копию текущей Object. (Унаследовано от Object) |
| ToString() |
Возвращает строку, представляющую текущий объект. (Унаследовано от Object) |
Явные реализации интерфейса
| Имя | Описание |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Сопоставляет набор имен соответствующему набору идентификаторов диспетчеризации. (Унаследовано от Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Извлекает сведения о типе объекта, который можно использовать для получения сведений о типе для интерфейса. (Унаследовано от Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Возвращает количество предоставляемых объектом интерфейсов для доступа к сведениям о типе (0 или 1). (Унаследовано от Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Предоставляет доступ к свойствам и методам, предоставляемым объектом. (Унаследовано от Attribute) |