PrivateComponentAttribute Класс

Определение

Определяет компонент в качестве частного компонента, который является видимым и активируемым только компонентами в том же самом приложении. Этот класс не наследуется.

public ref class PrivateComponentAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)]
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class PrivateComponentAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
type PrivateComponentAttribute = class
    inherit Attribute
Public NotInheritable Class PrivateComponentAttribute
Inherits Attribute
Наследование
PrivateComponentAttribute
Атрибуты

Примеры

В следующем примере кода показано использование PrivateComponentAttribute типа .

#using <System.EnterpriseServices.dll>

using namespace System;
using namespace System::EnterpriseServices;

// References:
// System.EnterpriseServices


// Note: Access checks must be performed at the component level to allow access
// to private components.
[assembly: ApplicationAccessControl(false,
AccessChecksLevel=AccessChecksLevelOption::ApplicationComponent)];

[PrivateComponent]
public ref class PrivateComponentAttributeExample : public ServicedComponent
{
public:
    void DisplayMessage()
    {
        // Display some output.
        Console::WriteLine("Private component called successfully.");
    }
};

public ref class PrivateComponentAttributeTest : public ServicedComponent
{
public:
    static void Test()
    {
        // Create a new instance of the example class.
        PrivateComponentAttributeExample^ example =
            gcnew PrivateComponentAttributeExample();

        // Call a method on the class.
        example->DisplayMessage();
    }
};
using System;
using System.EnterpriseServices;
using System.Reflection;

// References:
// System.EnterpriseServices


// Note: Access checks must be performed at the component level to allow access
// to private components.
[assembly: ApplicationAccessControl(false,
AccessChecksLevel=AccessChecksLevelOption.ApplicationComponent)]

[PrivateComponent]
public class PrivateComponentAttribute_Example : ServicedComponent
{
    public void Example()
    {
        // Display some output.
        Console.WriteLine("Private component called successfully.");
    }
}

public class PrivateComponentAttribute_Test : ServicedComponent
{
    public void Test()
    {
        // Create a new instance of the example class.
        PrivateComponentAttribute_Example example =
            new PrivateComponentAttribute_Example();

        // Call a method on the class.
        example.Example();
    }
}
Imports System.EnterpriseServices
Imports System.Reflection


' References:
' System.EnterpriseServices

' Note: Access checks must be performed at the component level to allow access
' to private components.

<assembly: ApplicationAccessControl(False, AccessChecksLevel := AccessChecksLevelOption.ApplicationComponent)>


<PrivateComponent()>  _
Public Class PrivateComponentAttribute_Example
    Inherits ServicedComponent
    
    Public Sub Example() 
        ' Display some output.
        MsgBox("Private component called successfully.")
    
    End Sub
End Class

Public Class PrivateComponentAttribute_Test
    Inherits ServicedComponent
    
    Public Sub Test() 
        ' Create a new instance of the example class.
        Dim example As New PrivateComponentAttribute_Example()
        
        ' Call a method on the class.
        example.Example()
    
    End Sub
End Class

Комментарии

Дополнительные сведения об использовании атрибутов см. в разделе Атрибуты.

Конструкторы

PrivateComponentAttribute()

Инициализирует новый экземпляр класса PrivateComponentAttribute.

Свойства

TypeId

В случае реализации в производном классе возвращает уникальный идентификатор для этого атрибута Attribute.

(Унаследовано от Attribute)

Методы

Equals(Object)

Возвращает значение, показывающее, равен ли экземпляр указанному объекту.

(Унаследовано от Attribute)
GetHashCode()

Возвращает хэш-код данного экземпляра.

(Унаследовано от Attribute)
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)

Применяется к