this ve takip eden this sayesinde, ne aradığımı buldum.
IParameterInspector
IOperationBehavior
seviyesinde olması gerekmez. IServiceBehavior
seviyesinde olabilirler. Servis seviyesi ApplyDispatchBehavior
yönteminde tüm işlemlerini gerçekleştirmeli ve denetçi davranışını atamalısınız. Tam benim sınıf
...
[AttributeUsage(AttributeTargets.Class)]
public class ServiceLevelParameterInspectorAttribute : Attribute, IParameterInspector, IServiceBehavior
{
public object BeforeCall(string operationName, object[] inputs)
{
// Inspect the parameters.
return null;
}
public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
{
}
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
}
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
{
}
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers)
{
if (channelDispatcher == null)
{
continue;
}
foreach(var endPoint in channelDispatcher.Endpoints)
{
if (endPoint == null)
{
continue;
}
foreach(var opertaion in endPoint.DispatchRuntime.Operations)
{
opertaion.ParameterInspectors.Add(this);
}
}
}
}
}
Biraz eski, ama kodunuzda aramaları devam neden? – itchi
@itchi Daha da büyük, ama tahmin ediyorum çünkü "Koleksiyon, ChannelDispatcherBase nesnelerini (ve sadece ChannelDispatcher örneklerini değil) içerir, çünkü Windows Communication Foundation (WCF) programlama modelini tutmak isteyen geliştiriciler tarafından da kullanılır. sistem tarafından sağlanan çalışma zamanı ". Kod geçersiz bir özel durum istisnasını tetikleyebilir gibi görünüyor. ChannelDispatcherBase'i kullanmak ve "as" operatörünü kullanmak daha iyi olur. – trydis