Guest User

Untitled

a guest
Apr 16th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. public class ServiceBehaviorEvents : IServiceBehavior
  2. {
  3. public event Action<ServiceDescription, ServiceHostBase> ApplyDispatchBehavior;
  4. public event Action<ServiceDescription, ServiceHostBase, Collection<ServiceEndpoint>, BindingParameterCollection> AddBindingParameters;
  5. public event Action<ServiceDescription, ServiceHostBase> Validate;
  6.  
  7. public static ServiceBehaviorEvents Install(ServiceHostBase host)
  8. {
  9. var evt = new ServiceBehaviorEvents();
  10. host.Description.Behaviors.Add(evt);
  11. return evt;
  12. }
  13.  
  14. void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
  15. {
  16. var evt = this.AddBindingParameters;
  17. if (evt != null)
  18. {
  19. evt(serviceDescription, serviceHostBase, endpoints, bindingParameters);
  20. }
  21. }
  22.  
  23. void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
  24. {
  25. var evt = this.ApplyDispatchBehavior;
  26. if (evt != null)
  27. {
  28. evt(serviceDescription, serviceHostBase);
  29. }
  30. }
  31.  
  32. void IServiceBehavior.Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
  33. {
  34. var evt = this.Validate;
  35. if (evt != null)
  36. {
  37. evt(serviceDescription, serviceHostBase);
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment