LicenseProviderAttribute クラス
アセンブリ: System (system.dll 内)
構文
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple:=False, Inherited:=False)> _ Public NotInheritable Class LicenseProviderAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=false, Inherited=false)] public sealed class LicenseProviderAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple=false, Inherited=false)] public ref class LicenseProviderAttribute sealed : public Attribute
ライセンスを受けるコンポーネントを作成する場合は、LicenseProviderAttribute でコンポーネントをマークすることによって、LicenseProvider を指定する必要があります。
LicenseProvider の Type を取得するには、LicenseProvider プロパティを使用します。
属性の詳細については、「属性の概要」と「属性を使用したメタデータの拡張」を参照してください。ライセンスの詳細については、「方法 : コンポーネントおよびコントロールのライセンス処理を行う」を参照してください。
メモ |
---|
このクラスに適用される HostProtectionAttribute 属性の Resources プロパティの値は、SharedState です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的には、アイコンをダブルクリック、コマンドを入力、またはブラウザに URL を入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラスのトピックまたは「SQL Server プログラミングとホスト保護属性」を参照してください。 |
LicFileLicenseProvider を MyControl のライセンス プロバイダとして使用するコード例を次に示します。
<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
[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(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. */ } };
/** @attribute LicenseProvider(LicFileLicenseProvider.class) */ public class MyControl extends Control { // Insert code here. protected void Dispose(boolean disposing) { /* All components must dispose of the licenses they grant. Insert code here to dispose of the license. */ } //Dispose } //MyControl
public LicenseProvider(LicFileLicenseProvider) class MyControl extends Control{ // Insert code here. function Dispose(){ // All components must dispose of the licenses they grant. // Insert code here to dispose of the license. } //Dispose } //MyControl
MyControl クラスのインスタンスを作成するコード例を次に示します。そのクラスの属性を取得し、myNewControl で使用するライセンス プロバイダの名前を出力します。
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
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; }
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 void main(String[] args) { // Creates a new component. Class1 lObjClass1 = new Class1(); MyControl myNewControl = lObjClass1.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.get_Item(LicenseProviderAttribute.class.ToType()))); Console.WriteLine(("The license provider for this class is: " + myAttribute.get_LicenseProvider().ToString())); } //main
// Creates a new component. var myNewControl : MyControl = new MyControl() // Gets the attributes for the component. var attributes : AttributeCollection = TypeDescriptor.GetAttributes(myNewControl) // Prints the name of the license provider by retrieving the LicenseProviderAttribute // from the AttributeCollection. var myAttribute : LicenseProviderAttribute = LicenseProviderAttribute(attributes(LicenseProviderAttribute)) Console.WriteLine("The license provider for this class is: " + myAttribute.LicenseProvider.ToString())
System.Attribute
System.ComponentModel.LicenseProviderAttribute
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- LicenseProviderAttribute クラスのページへのリンク