MyClientBehavior.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:MyClientBehavior.cs
  5. * 2.功能描述:客户端终结点行为的行为扩展
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2014/08/13 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.ServiceModel.Channels;
  12. using System.ServiceModel.Configuration;
  13. using System.ServiceModel.Description;
  14. using System.ServiceModel.Dispatcher;
  15. namespace Dongke.IBOSS.PRD.WCF.Proxys.ClientInterpector
  16. {
  17. /// <summary>
  18. /// 客户端终结点行为的行为扩展
  19. /// </summary>
  20. public class MyClientBehavior : BehaviorExtensionElement, IEndpointBehavior
  21. {
  22. /// <summary>
  23. /// 获取行为的类型
  24. /// </summary>
  25. public override Type BehaviorType
  26. {
  27. get
  28. {
  29. return typeof(MyClientBehavior);
  30. }
  31. }
  32. /// <summary>
  33. /// 基于当前配置设置来创建行为扩展
  34. /// </summary>
  35. /// <returns>行为扩展</returns>
  36. protected override object CreateBehavior()
  37. {
  38. return new MyClientBehavior();
  39. }
  40. #region IEndpointBehavior Members
  41. /// <summary>
  42. /// 实现此方法可以在运行时将数据传递给绑定,从而支持自定义行为
  43. /// </summary>
  44. /// <param name="endpoint">要修改的终结点</param>
  45. /// <param name="bindingParameters">绑定元素支持该行为所需的对象</param>
  46. public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
  47. {
  48. }
  49. /// <summary>
  50. /// 在终结点范围内实现客户端的修改或扩展
  51. /// </summary>
  52. /// <param name="endpoint">要自定义的终结点</param>
  53. /// <param name="clientRuntime">要自定义的客户端运行时</param>
  54. public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
  55. {
  56. clientRuntime.MessageInspectors.Add(new ClientInterpector());
  57. }
  58. /// <summary>
  59. /// 在终结点范围内实现客户端的修改或扩展
  60. /// </summary>
  61. /// <param name="endpoint">公开协定的终结点</param>
  62. /// <param name="endpointDispatcher">要修改或扩展的终结点调度程序</param>
  63. public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
  64. {
  65. }
  66. /// <summary>
  67. /// 现此方法可以确认终结点是否满足某些设定条件
  68. /// </summary>
  69. /// <param name="endpoint">要验证的终结点</param>
  70. public void Validate(ServiceEndpoint endpoint)
  71. {
  72. }
  73. #endregion
  74. }
  75. }