BestFitMappingAttribute 클래스

정의

유니코드 문자가 가장 일치하는 ANSI 문자로 변환되는지 여부를 제어합니다.

public ref class BestFitMappingAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)]
public sealed class BestFitMappingAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class BestFitMappingAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)>]
type BestFitMappingAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type BestFitMappingAttribute = class
    inherit Attribute
Public NotInheritable Class BestFitMappingAttribute
Inherits Attribute
상속
BestFitMappingAttribute
특성

예제

다음 예제에서는 최상의 맞춤 매핑을 사용하지 않도록 설정하고 유니코드 문자를 '?'로 변환할 때 예외를 throw하는 방법을 보여줍니다. ANSI 문자입니다. 이러한 방식으로 매개 변수를 설정 BestFitMappingAttribute 하면 추가된 보안 측정값이 제공됩니다.

[BestFitMapping(false, ThrowOnUnmappableChar = true)]
interface class IMyInterface1
{
     //Insert code here.
};
[BestFitMapping(false, ThrowOnUnmappableChar = true)]
interface IMyInterface1
{
     //Insert code here.
}
<BestFitMapping(False, ThrowOnUnmappableChar := True)> _
Interface IMyInterface1
     'Insert code here.
End Interface

설명

어셈블리, 인터페이스, 클래스 또는 구조체에 이 특성을 적용할 수 있습니다.

Caution

일부 문자는 가장 적합한 표현이 부족합니다. 이러한 문자를 적용할 수 없는 문자라고 합니다. 적용할 수 없는 문자는 일반적으로 기본 '?'으로 변환됩니다. ANSI 문자입니다. 특정 유니코드 문자는 실수로 경로를 변경할 수 있는 백슬래시 '\' 문자와 같은 위험한 문자로 변환됩니다.

BestFitMappingAttribute 는 최적 매핑의 측면을 제어하는 두 개의 매개 변수를 제공합니다. 첫 번째 매개 변수를 사용하여 최적 매핑을 설정/해제합니다. 기본값은 true어셈블리, 인터페이스 및 클래스 수준에서 가장 적합한 매핑을 사용하도록 설정하는 것입니다. 인터페이스 또는 클래스에 적용된 특성은 어셈블리 수준 특성을 재정의합니다. 마찬가지로 필드를 사용하여 DllImportAttribute.BestFitMapping 플랫폼 호출에 가장 적합한 매핑을 사용하거나 사용하지 않도록 설정할 수 있습니다. 플랫폼 호출 필드에 의해 설정된 값은 모든 수준의 을 재정의 BestFitMappingAttribute합니다.

두 번째 매개 변수를 사용하여 적용할 수 없는 문자에 대한 예외 throw를 제어할 수 있습니다. 필드의 ThrowOnUnmappableChar 기본값은 false런타임에서 '?'로 변환해야 하는 유니코드 문자를 발견할 때마다 예외를 throw하지 않도록 설정하는 것입니다. ANSI 문자입니다. 가장 적합한 매핑이더라도 필드trueThrowOnUnmappableChar있는 경우 적용할 수 없는 문자는 예외를 true 생성합니다. 보안을 강화하려면 첫 번째 매개 변수를 토글하고 두 번째 매개 변수를 false .로 전환할 true수 있습니다. 이 매개 변수 설정 조합은 가장 적합한 매핑을 해제하지만, 안전 예방 조치로 예외 throw 메커니즘을 사용하도록 설정합니다.

Caution

해당 요소가 ANSI Chars 또는 LPSTR인 관리형 배열을 관리되지 않는 안전한 배열에 전달할 때 제공되는 BestFitMappingAttribute 기본값은 변경할 수 없습니다. 최적 매핑은 항상 사용하도록 설정되며 예외를 throw할 수 없습니다. 이 조합은 보안 모델을 손상시킬 수 있습니다.

생성자

Name Description
BestFitMappingAttribute(Boolean)

속성 값으로 설정된 클래스의 BestFitMappingAttribute 새 인스턴스를 BestFitMapping 초기화합니다.

필드

Name Description
ThrowOnUnmappableChar

ANSI '?' 문자로 변환되는 매핑할 수 없는 유니코드 문자에서 예외를 throw하거나 사용하지 않도록 설정합니다.

속성

Name Description
BestFitMapping

유니코드 문자를 ANSI 문자로 변환할 때 가장 적합한 매핑 동작을 가져옵니다.

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)

적용 대상

추가 정보