OutAttribute 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
호출 수신자에서 호출자로 데이터를 마샬링해야 임을 나타냅니다.
public ref class OutAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Parameter, Inherited=false)]
public sealed class OutAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Parameter, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OutAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Parameter, Inherited=false)>]
type OutAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Parameter, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type OutAttribute = class
inherit Attribute
Public NotInheritable Class OutAttribute
Inherits Attribute
- 상속
- 특성
예제
다음 예제에서는 배열을 매개 변수로 전달하는 프로토타입을 플랫폼 호출에 적용 InAttributeOutAttribute 하는 방법을 보여 줍니다. 방향 특성의 조합을 사용하면 호출자가 호출자가 변경한 내용을 볼 수 있습니다.
using namespace System;
using namespace System::Runtime::InteropServices;
// Declare a class member for each structure element.
[StructLayout(LayoutKind::Sequential, CharSet = CharSet::Unicode)]
public ref class OpenFileName
{
public:
int structSize;
String^ filter;
String^ file;
// ...
};
private ref class NativeMethods
{
public:
// Declare a managed prototype for the unmanaged function.
[DllImport("Comdlg32.dll", CharSet = CharSet::Unicode)]
static bool GetOpenFileName([In, Out]OpenFileName^ ofn);
};
void main() {}
using System.Runtime.InteropServices;
using System;
// Declare a class member for each structure element.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public class OpenFileName
{
public int structSize = 0;
public string filter = null;
public string file = null;
// ...
}
internal static class NativeMethods
{
// Declare a managed prototype for the unmanaged function.
[DllImport("Comdlg32.dll", CharSet = CharSet.Unicode)]
internal static extern bool GetOpenFileName([In, Out] OpenFileName ofn);
}
public class MainMethod
{
static void Main()
{ }
}
Imports System.Runtime.InteropServices
' Declare a class member for each structure element.
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Class OpenFileName
Public structSize As Integer = 0
Public filter As String = Nothing
Public file As String = Nothing
' ...
End Class
Friend Class NativeMethods
' Declare managed prototype for the unmanaged function.
Friend Declare Unicode Function GetOpenFileName Lib "Comdlg32.dll" (
<[In](), Out()> ByVal ofn As OpenFileName) As Boolean
End Class
Public Class App
Public Shared Sub Main()
End Sub
End Class
설명
매개 변수에 이 특성을 적용할 수 있습니다.
선택 OutAttribute 사항입니다. 이 특성은 COM interop 및 플랫폼 호출에 대해서만 지원됩니다. 명시적 설정이 없는 경우 interop 마샬러는 매개 변수 형식, 매개 변수가 참조로 전달되는지 값으로 전달되는지 여부, 형식이 Blittable인지 아니면 Blittable이 아닌지를 기준으로 규칙을 가정합니다. 예를 들어 StringBuilder 클래스는 항상 In/Out으로 간주되며 값으로 전달된 문자열 배열은 In으로 간주됩니다.
아웃 전용 동작은 매개 변수에 대한 기본 마샬링 동작이 되지 않습니다. 참조로 OutAttribute 전달된 값 및 참조 형식을 적용하여 In/Out 동작을 C#의 키워드를 사용하는 out 것과 동일한 Out 전용 동작으로 변경할 수 있습니다. 예를 들어 기본적으로 In-only 매개 변수로 마샬링된 값으로 전달된 배열은 Out 전용으로 변경할 수 있습니다. 그러나 interop 마샬러가 고정을 사용하기 때문에 형식에 모든 blittable 요소 또는 필드가 포함된 경우 동작이 항상 예상 의미 체계를 제공하지는 않습니다. 데이터를 호출 수신자로 전달하는 데 신경 쓰지 않는 경우 아웃 전용 마샬링이 Blittable이 아닌 형식에 대해 더 나은 성능을 제공할 수 있습니다.
InAttribute 배열 및 OutAttribute 서식이 지정된 Blittable이 아닌 형식에 적용할 때 특히 유용합니다. 호출자는 두 특성을 모두 적용할 때만 호출자가 이러한 형식에 대해 변경한 내용을 확인합니다. 이러한 형식은 마샬링하는 동안 복사가 필요하므로 불필요한 복사본을 사용하고 InAttributeOutAttribute 줄일 수 있습니다.
생성자
| Name | Description |
|---|---|
| OutAttribute() |
OutAttribute 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| TypeId |
파생 클래스에서 구현되는 경우 이 Attribute대한 고유 식별자를 가져옵니다. (다음에서 상속됨 Attribute) |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다. (다음에서 상속됨 Attribute) |
| GetHashCode() |
이 인스턴스의 해시 코드를 반환합니다. (다음에서 상속됨 Attribute) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| IsDefaultAttribute() |
파생 클래스에서 재정의되는 경우 이 인스턴스의 값이 파생 클래스의 기본값인지 여부를 나타냅니다. (다음에서 상속됨 Attribute) |
| Match(Object) |
파생 클래스에서 재정의되는 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다. (다음에서 상속됨 Attribute) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
명시적 인터페이스 구현
| Name | Description |
|---|---|
| _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) |