ldj/WcfServiceAuthentication/AuthenticationBehavior.cs

30 lines
1.2 KiB
C#
Raw Normal View History

2023-05-23 16:13:17 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace WcfServiceAuthentication
{
public class AuthenticationBehavior : IServiceBehavior
{
public void AddBindingParameters(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
}
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher cDispatcher in serviceHostBase.ChannelDispatchers)
foreach (EndpointDispatcher endpointDispatcher in cDispatcher.Endpoints)
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(
new AuthenticationInspector());
}
public void Validate(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
}
}
}