IParameterInspector 인터페이스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
클라이언트 또는 서비스에서 호출 이전 및 이후의 정보를 검사 또는 수정할 수 있는 사용자 지정 매개 변수 검사자를 통해 구현되는 계약을 정의합니다.
public interface class IParameterInspector
public interface IParameterInspector
type IParameterInspector = interface
Public Interface IParameterInspector
예제
다음 코드 예제에서는 다음 구현을 IParameterInspector 보여 제공합니다.
서비스에 의해 응답이 역직렬화되었거나 클라이언트가 요청을 직렬화한 후 작업 이름과 반환 값을 콘솔에 씁니다.
클라이언트에서 응답을 역직렬화한 후 또는 서비스에서 응답이 serialize된 후 콘솔에 작업 이름을 씁니다.
#region IParameterInspector Members
public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
{
Console.WriteLine(
"IParameterInspector.AfterCall called for {0} with return value {1}.",
operationName,
returnValue.ToString()
);
}
public object BeforeCall(string operationName, object[] inputs)
{
Console.WriteLine("IParameterInspector.BeforeCall called for {0}.", operationName);
return null;
}
#Region "IParameterInspector Members"
Public Sub AfterCall(ByVal operationName As String, ByVal outputs() As Object, ByVal returnValue As Object, _
ByVal correlationState As Object) Implements IParameterInspector.AfterCall
Console.WriteLine("IParameterInspector.AfterCall called for {0} with return value {1}.", _
operationName, returnValue.ToString())
End Sub
Public Function BeforeCall(ByVal operationName As String, ByVal inputs() As Object) As Object Implements _
IParameterInspector.BeforeCall
Console.WriteLine("IParameterInspector.BeforeCall called for {0}.", operationName)
Return Nothing
End Function
다음 코드 예제에서는 개체를 사용 System.ServiceModel.Description.IOperationBehaviorSystem.ServiceModel.Description.IEndpointBehavior 하거나 System.ServiceModel.Description.IServiceBehavior 삽입 IParameterInspector 하는 방법을 보여줍니다.
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Text;
namespace Microsoft.WCF.Documentation
{
public class InspectorInserter : BehaviorExtensionElement, IServiceBehavior, IEndpointBehavior, IOperationBehavior
{
#region IServiceBehavior Members
public void AddBindingParameters(
ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase,
System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints,
BindingParameterCollection bindingParameters
)
{ return; }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher chDisp in serviceHostBase.ChannelDispatchers)
{
foreach (EndpointDispatcher epDisp in chDisp.Endpoints)
{
epDisp.DispatchRuntime.MessageInspectors.Add(new Inspector());
foreach (DispatchOperation op in epDisp.DispatchRuntime.Operations)
op.ParameterInspectors.Add(new Inspector());
}
}
}
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase){ return; }
#endregion
#region IEndpointBehavior Members
public void AddBindingParameters(
ServiceEndpoint endpoint, BindingParameterCollection bindingParameters
) { return; }
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(new Inspector());
foreach (ClientOperation op in clientRuntime.Operations)
op.ParameterInspectors.Add(new Inspector());
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new Inspector());
foreach (DispatchOperation op in endpointDispatcher.DispatchRuntime.Operations)
op.ParameterInspectors.Add(new Inspector());
}
public void Validate(ServiceEndpoint endpoint){ return; }
#endregion
#region IOperationBehavior Members
public void AddBindingParameters(
OperationDescription operationDescription, BindingParameterCollection bindingParameters
)
{ return; }
public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
{
clientOperation.ParameterInspectors.Add(new Inspector());
}
public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
{
dispatchOperation.ParameterInspectors.Add(new Inspector());
}
public void Validate(OperationDescription operationDescription){ return; }
#endregion
public override Type BehaviorType
{
get { return typeof(InspectorInserter); }
}
protected override object CreateBehavior()
{ return new InspectorInserter(); }
}
}
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.ServiceModel.Configuration
Imports System.ServiceModel.Description
Imports System.ServiceModel.Dispatcher
Imports System.Text
Namespace Microsoft.WCF.Documentation
Public Class InspectorInserter
Inherits BehaviorExtensionElement
Implements IServiceBehavior, IEndpointBehavior, IOperationBehavior
#Region "IServiceBehavior Members"
Public Sub AddBindingParameters(ByVal serviceDescription As ServiceDescription, _
ByVal serviceHostBase As ServiceHostBase, ByVal endpoints As _
System.Collections.ObjectModel.Collection(Of ServiceEndpoint), _
ByVal bindingParameters As BindingParameterCollection) Implements IServiceBehavior.AddBindingParameters
Return
End Sub
Public Sub ApplyDispatchBehavior(ByVal serviceDescription As ServiceDescription, _
ByVal serviceHostBase As ServiceHostBase) Implements _
IServiceBehavior.ApplyDispatchBehavior
For Each chDisp As ChannelDispatcher In serviceHostBase.ChannelDispatchers
For Each epDisp As EndpointDispatcher In chDisp.Endpoints
epDisp.DispatchRuntime.MessageInspectors.Add(New Inspector())
For Each op As DispatchOperation In epDisp.DispatchRuntime.Operations
op.ParameterInspectors.Add(New Inspector())
Next op
Next epDisp
Next chDisp
End Sub
Public Sub Validate(ByVal serviceDescription As ServiceDescription, ByVal serviceHostBase As ServiceHostBase) _
Implements IServiceBehavior.Validate
Return
End Sub
#End Region
#Region "IEndpointBehavior Members"
Public Sub AddBindingParameters(ByVal endpoint As ServiceEndpoint, ByVal bindingParameters _
As BindingParameterCollection) Implements IEndpointBehavior.AddBindingParameters
Return
End Sub
Public Sub ApplyClientBehavior(ByVal endpoint As ServiceEndpoint, ByVal clientRuntime As ClientRuntime) _
Implements IEndpointBehavior.ApplyClientBehavior
clientRuntime.MessageInspectors.Add(New Inspector())
For Each op As ClientOperation In clientRuntime.Operations
op.ParameterInspectors.Add(New Inspector())
Next op
End Sub
Public Sub ApplyDispatchBehavior(ByVal endpoint As ServiceEndpoint, ByVal endpointDispatcher As _
EndpointDispatcher) Implements IEndpointBehavior.ApplyDispatchBehavior
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(New Inspector())
For Each op As DispatchOperation In endpointDispatcher.DispatchRuntime.Operations
op.ParameterInspectors.Add(New Inspector())
Next op
End Sub
Public Sub Validate(ByVal endpoint As ServiceEndpoint) Implements IEndpointBehavior.Validate
Return
End Sub
#End Region
#Region "IOperationBehavior Members"
Public Sub AddBindingParameters(ByVal operationDescription As OperationDescription, _
ByVal bindingParameters As BindingParameterCollection) Implements _
IOperationBehavior.AddBindingParameters
Return
End Sub
Public Sub ApplyClientBehavior(ByVal operationDescription As OperationDescription, ByVal _
clientOperation As ClientOperation) Implements IOperationBehavior.ApplyClientBehavior
clientOperation.ParameterInspectors.Add(New Inspector())
End Sub
Public Sub ApplyDispatchBehavior(ByVal operationDescription As OperationDescription, ByVal dispatchOperation As _
DispatchOperation) Implements IOperationBehavior.ApplyDispatchBehavior
dispatchOperation.ParameterInspectors.Add(New Inspector())
End Sub
Public Sub Validate(ByVal operationDescription As OperationDescription) Implements IOperationBehavior.Validate
Return
End Sub
#End Region
Public Overrides ReadOnly Property BehaviorType() As Type
Get
Return GetType(InspectorInserter)
End Get
End Property
Protected Overrides Function CreateBehavior() As Object
Return New InspectorInserter()
End Function
End Class
End Namespace
설명
클라이언트 또는 서비스 애플리케이션 중에서 호출 이전과 이후에 해당 호출의 내용을 보고 수정할 수 있는 사용자 지정 매개 변수 검사자를 만들려면 IParameterInspector 인터페이스를 구현하십시오.
클라이언트의 아웃바운드 호출에서 요청 내용이 직렬화되어 서비스로 전송되기 전에 검사자가 호출됩니다. 또한 응답이 역직렬화되었지만 반환 값이 프록시 메서드로 디스패치되기 전에 검사기가 호출됩니다.
서비스에 대한 인바운드 호출에서 매개 변수가 역직렬화된 후 서비스 작업으로 디스패치되기 전에 검사기가 호출됩니다.
ClientOperation.ParameterInspectors 속성 또는 DispatchOperation.ParameterInspectors 속성을 사용하여 특정 작업에 대한 검사기 컬렉션에 구현을 추가 IParameterInspector 합니다.
참고 개발자와 관리자는 다른 IParameterInspector 구현과의 상호 작용을 이해해야 합니다.
메서드
AfterCall(String, Object[], Object, Object) |
클라이언트 호출이 반환된 후와 서비스 응답이 보내지기 전에 호출됩니다. |
BeforeCall(String, Object[]) |
클라이언트 호출이 보내지기 전과 서비스 응답이 반환된 후에 호출됩니다. |