SoapExtension.GetInitializer 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
파생 클래스에서 재정의되는 경우 SOAP 확장에서 XML 웹 서비스 메서드와 관련된 데이터를 한 번에 성능 비용으로 초기화할 수 있습니다.
오버로드
| Name | Description |
|---|---|
| GetInitializer(Type) |
파생 클래스에서 재정의되는 경우 SOAP 확장에서 한 번에 성능 비용으로 XML 웹 서비스를 구현하는 클래스와 관련된 데이터를 초기화할 수 있습니다. |
| GetInitializer(LogicalMethodInfo, SoapExtensionAttribute) |
파생 클래스에서 재정의된 경우 SOAP 확장에서 XML 웹 서비스 메서드에 적용된 특성을 사용하여 XML 웹 서비스 메서드와 관련된 데이터를 한 번에 성능 비용으로 초기화할 수 있습니다. |
GetInitializer(Type)
파생 클래스에서 재정의되는 경우 SOAP 확장에서 한 번에 성능 비용으로 XML 웹 서비스를 구현하는 클래스와 관련된 데이터를 초기화할 수 있습니다.
public:
abstract System::Object ^ GetInitializer(Type ^ serviceType);
public abstract object GetInitializer(Type serviceType);
abstract member GetInitializer : Type -> obj
Public MustOverride Function GetInitializer (serviceType As Type) As Object
매개 변수
- serviceType
- Type
SOAP 확장이 적용되는 XML 웹 서비스를 구현하는 클래스의 형식입니다.
반품
Object SOAP 확장이 캐싱을 위해 초기화하는 것입니다.
예제
다음 코드는 XML 웹 서비스별로 SOAP 확장 특정 데이터를 저장하는 방법을 보여 줍니다. SOAP 확장이 특성 대신 구성 파일을 사용하여 구성된 경우 SOAP 확장은 SOAP 확장이 적용되는 각 클래스에 대한 데이터를 저장할 수 있습니다. 이 예제에서는 XML 웹 서비스를 구현하는 클래스의 이름을 기반으로 XML 웹 서비스 메서드와 주고 받는 SOAP 메시지를 캐시에 기록할 파일의 이름을 저장합니다. 이 코드 예제는 클래스 개요에서 찾을 수 있는 TraceExtension SOAP 확장에 대한 전체 코드 예제의 SoapExtension 일부입니다.
// The extension was configured to run using a configuration file instead of an attribute applied to a
// specific XML Web service method. Return a file name based on the class implementing the XML Web service's type.
public:
virtual Object^ GetInitializer( Type^ WebServiceType ) override
{
// Return a file name to log the trace information to based on the passed in type.
return String::Format( "C:\\{0}.log", WebServiceType->FullName );
}
// The extension was configured to run using a configuration file instead of an attribute applied to a
// specific XML Web service method. Return a file name based on the class implementing the XML Web service's type.
public override object GetInitializer(Type WebServiceType)
{
// Return a file name to log the trace information to based on the passed in type.
return "C:\\" + WebServiceType.FullName + ".log";
}
' The extension was configured to run using a configuration file instead of an attribute applied to a
' specific XML Web service method. Return a file name based on the class implementing the XML Web service's type.
Public Overloads Overrides Function GetInitializer(WebServiceType As Type) As Object
' Return a file name to log the trace information to based on the passed in type.
Return "C:\" + WebServiceType.FullName + ".log"
End Function
설명
ASP.NET 호출되는 GetInitializer 오버로드는 SOAP 확장이 지정된 방법에 따라 달라집니다. SOAP 확장을 지정하는 방법에는 두 가지가 있습니다.
파생되는 SoapExtensionAttribute사용자 지정 특성을 개별 XML 웹 서비스 메서드에 적용합니다.
web.config 또는 app.config 구성 파일에 참조를 추가합니다.
구성 파일 중 하나에 대한 참조를 추가하는 경우 SOAP 확장은 해당 구성 파일 범위 내의 모든 XML 웹 서비스에 대해 실행됩니다. 구성 파일을 참조하여 SOAP 확장을 지정할 때 ASP.NET GetInitializer 전달되는 Type 오버로드를 호출합니다. 사용자 지정 특성을 적용하여 확장을 지정할 때 ASP.NET GetInitializer 및 LogicalMethodInfo 전달하는 SoapExtensionAttribute 호출합니다.
구성 파일에 SOAP 확장을 추가하는 방법에 대한 자세한 내용은
적용 대상
GetInitializer(LogicalMethodInfo, SoapExtensionAttribute)
파생 클래스에서 재정의된 경우 SOAP 확장에서 XML 웹 서비스 메서드에 적용된 특성을 사용하여 XML 웹 서비스 메서드와 관련된 데이터를 한 번에 성능 비용으로 초기화할 수 있습니다.
public:
abstract System::Object ^ GetInitializer(System::Web::Services::Protocols::LogicalMethodInfo ^ methodInfo, System::Web::Services::Protocols::SoapExtensionAttribute ^ attribute);
public abstract object GetInitializer(System.Web.Services.Protocols.LogicalMethodInfo methodInfo, System.Web.Services.Protocols.SoapExtensionAttribute attribute);
abstract member GetInitializer : System.Web.Services.Protocols.LogicalMethodInfo * System.Web.Services.Protocols.SoapExtensionAttribute -> obj
Public MustOverride Function GetInitializer (methodInfo As LogicalMethodInfo, attribute As SoapExtensionAttribute) As Object
매개 변수
- methodInfo
- LogicalMethodInfo
LogicalMethodInfo SOAP 확장이 적용되는 XML 웹 서비스 메서드의 특정 함수 프로토타입을 나타내는 형식입니다.
- attribute
- SoapExtensionAttribute
SoapExtensionAttribute XML 웹 서비스 메서드에 적용된 것입니다.
반품
Object SOAP 확장이 캐싱을 위해 초기화하는 것입니다.
예제
다음 코드에서는 파생 SoapExtensionAttribute되는 클래스를 사용하여 전달된 SOAP 확장 관련 데이터를 가져온 다음 해당 데이터를 GetInitializer캐시하는 방법을 보여 줍니다. 이 코드 예제는 클래스 개요에서 찾을 수 있는 TraceExtension SOAP 확장에 대한 전체 코드 예제의 SoapExtension 일부입니다. 이 코드 예제에서는 매개 변수에 전달되는 TraceExtensionAttribute 것을 사용합니다attribute. 전체 코드 예제 TraceExtensionAttribute 에서 파생 SoapExtensionAttribute 하 고 캐시에 저장 되는 Filename 속성을 추가 GetInitializer 합니다.
public:
// When the SOAP extension is accessed for the first time, cache the
// file name passed in by the SoapExtensionAttribute.
virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) override
{
return (dynamic_cast<TraceExtensionAttribute^>(attribute))->Filename;
}
// When the SOAP extension is accessed for the first time, cache the
// file name passed in by the SoapExtensionAttribute.
public override object GetInitializer(LogicalMethodInfo methodInfo,
SoapExtensionAttribute attribute)
{
return ((TraceExtensionAttribute) attribute).Filename;
}
' When the SOAP extension is accessed for the first time,
' cache the file name passed in by the SoapExtensionAttribute.
Public Overloads Overrides Function GetInitializer( _
methodInfo As LogicalMethodInfo, _
attribute As SoapExtensionAttribute) As Object
Return CType(attribute, TraceExtensionAttribute).Filename
End Function
설명
구성 파일을 사용하여 SOAP 확장이 구성된 경우 을 GetInitializer 허용하는 Type오버로드가 표시됩니다.
SOAP 확장에는 데이터를 초기화할 수 있는 세 가지 기회가 있으며 모두 다른 용도로 사용됩니다.
클래스 생성자 - SOAP 확장이 인스턴스화될 때마다 클래스 생성자가 호출되며 일반적으로 멤버 변수를 초기화하는 데 사용됩니다.
GetInitializer - GetInitializer그러나 XML Web services 메서드에 대한 SOAP 요청이 처음 이루어지면 한 번만 호출됩니다. 사용자 지정 특성이 XML 웹 서비스 메서드에 적용되면 메서드가 GetInitializer 호출됩니다. 이렇게 하면 SOAP 확장에서 프로토타입 정보에 대한 XML 웹 서비스 메서드를 심문 LogicalMethodInfo 하거나 파생 클래스에서 SoapExtensionAttribute전달된 확장 관련 데이터에 액세스할 수 있습니다. 반환 값은 ASP.NET 의해 캐시되고 후속 Initialize 메서드로 전달됩니다. 따라서 초기화 GetInitializer 는 기본적으로 일회성 성능 적중으로 캡슐화됩니다.
Initialize - Initialize는 XML 웹 서비스 메서드에 SOAP 요청을 할 때마다 호출되지만 초기화된 항목이 이 메서드에 Object 전달된다는 측면에서 GetInitializer 클래스 생성자에 비해 이점이 있습니다.