小编Ema*_*ico的帖子

如何使用Simple Injector将dependdencis注入到WCF属性中

我有一堆与REST和SOAP一起使用的WCF服务.我创建了一个WCF属性,用于检查当前的httpcontext是否存在,如果存在,则使用cookie身份验证,其他方式使用自定义WCF身份验证.

我的属性如下所示:

Public Class AuthRequired
    Inherits Attribute
    Implements IOperationBehavior, IParameterInspector

    Public Sub AddBindingParameters(operationDescription As OperationDescription, bindingParameters As Channels.BindingParameterCollection) Implements IOperationBehavior.AddBindingParameters

    End Sub

    Public Sub ApplyClientBehavior(operationDescription As OperationDescription, clientOperation As ClientOperation) Implements IOperationBehavior.ApplyClientBehavior

    End Sub

    Public Sub ApplyDispatchBehavior(operationDescription As OperationDescription, dispatchOperation As DispatchOperation) Implements IOperationBehavior.ApplyDispatchBehavior
        dispatchOperation.ParameterInspectors.Add(Me)
    End Sub

    Public Sub Validate(operationDescription As OperationDescription) Implements IOperationBehavior.Validate

    End Sub

    Public Sub AfterCall(operationName As String, outputs() As Object, returnValue As Object, correlationState As Object) Implements IParameterInspector.AfterCall

    End Sub

    Public Function BeforeCall(operationName As String, inputs() …
Run Code Online (Sandbox Code Playgroud)

wcf attributes inversion-of-control simple-injector

5
推荐指数
1
解决办法
2655
查看次数