LicenseProviderAttribute Sınıf

Tanım

Bir sınıfla kullanılacak öğesini LicenseProvider belirtir. Bu sınıf devralınamaz.

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
Devralma
LicenseProviderAttribute
Öznitelikler

Örnekler

Aşağıdaki kod örneği için MyControllisans sağlayıcısı olarak kullanırLicFileLicenseProvider.

[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

Sonraki kod örneği sınıfının bir örneğini MyControl oluşturur. Ardından sınıfının özniteliklerini alır ve tarafından myNewControlkullanılan lisans sağlayıcısının adını yazdırır.

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

Açıklamalar

Lisanslamak istediğiniz bir bileşen oluşturduğunuzda, bileşeni ile LicenseProviderAttributeişaretleyerek öğesini belirtmeniz LicenseProvider gerekir.

LicenseProvider özelliğini kullanarak öğesinin LicenseProviderdeğerini alınType.

Öznitelikler hakkında daha fazla bilgi için bkz . Öznitelikler. Lisanslama hakkında daha fazla bilgi için bkz . Nasıl yapılır: Lisans Bileşenleri ve Denetimleri.

Not

HostProtectionAttribute Bu sınıfa uygulanan öznitelik şu Resources özellik değerine sahiptir: SharedState. HostProtectionAttribute masaüstü uygulamalarını etkilemez (bunlar normalde bir simge tıklatılarak, komut yazılarak veya tarayıcıya URL girilerek başlatılır). Daha fazla bilgi için bkzHostProtectionAttribute. Programlama ve Konak Koruması Öznitelikleri sınıfı veya SQL Server.

Oluşturucular

LicenseProviderAttribute()

Lisans sağlayıcısı olmadan sınıfının yeni bir örneğini LicenseProviderAttribute başlatır.

LicenseProviderAttribute(String)

Belirtilen türe sahip sınıfın LicenseProviderAttribute yeni bir örneğini başlatır.

LicenseProviderAttribute(Type)

Belirtilen lisans sağlayıcısı türüyle sınıfının yeni bir örneğini LicenseProviderAttribute başlatır.

Alanlar

Default

Sağlayıcı olmayan varsayılan değeri belirtir. Bu static alan salt okunur.

Özellikler

LicenseProvider

İlişkili sınıfla kullanılması gereken lisans sağlayıcısını alır.

TypeId

Bu öznitelik türü için benzersiz bir kimlik gösterir.

Yöntemler

Equals(Object)

Bu örnek ile belirtilen bir nesnenin eşit olup olmadığını gösterir.

GetHashCode()

Bu örneğe ilişkin karma kodu döndürür.

GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
IsDefaultAttribute()

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin değerinin türetilmiş sınıf için varsayılan değer olup olmadığını gösterir.

(Devralındığı yer: Attribute)
Match(Object)

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değer döndürür.

(Devralındığı yer: Attribute)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

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

Bir ad kümesini karşılık gelen bir dağıtma tanımlayıcısı kümesine eşler.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Bir arabirimin tür bilgilerini almak için kullanılabilecek bir nesnenin tür bilgilerini alır.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Bir nesnenin sağladığı tür bilgisi arabirimlerinin sayısını alır (0 ya da 1).

(Devralındığı yer: Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Bir nesne tarafından sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.