PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/WCFWebApi/src/Microsoft.ApplicationServer.Http/Microsoft/ApplicationServer/Http/Description/HttpMemoryBehavior.cs

#
C# | 94 lines | 60 code | 9 blank | 25 comment | 12 complexity | dac6b7b76e26c95bb0e03f2fbb996996 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, Apache-2.0
  1. // <copyright>
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. // </copyright>
  4. namespace Microsoft.ApplicationServer.Http.Description
  5. {
  6. using System;
  7. using System.ServiceModel;
  8. using System.ServiceModel.Channels;
  9. using System.ServiceModel.Description;
  10. using System.ServiceModel.Dispatcher;
  11. using Microsoft.ApplicationServer.Http;
  12. using Microsoft.Server.Common;
  13. /// <summary>
  14. /// Class that provides <see cref="IEndpointBehavior"/> for the <see cref="HttpMemoryBinding"/> binding.
  15. /// </summary>
  16. internal class HttpMemoryBehavior : IEndpointBehavior
  17. {
  18. private static readonly Type httpMemoryBehaviorType = typeof(HttpMemoryBehavior);
  19. /// <summary>
  20. /// Passes data at runtime to bindings to support custom behavior.
  21. /// </summary>
  22. /// <param name="endpoint">The endpoint to modify.</param>
  23. /// <param name="bindingParameters">The objects that binding elements require to support the behavior.</param>
  24. public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
  25. {
  26. if (endpoint == null)
  27. {
  28. throw Fx.Exception.ArgumentNull("endpoint");
  29. }
  30. if (bindingParameters == null)
  31. {
  32. throw Fx.Exception.ArgumentNull("bindingParameters");
  33. }
  34. }
  35. /// <summary>
  36. /// Implements a modification or extension of the client across an endpoint.
  37. /// </summary>
  38. /// <param name="endpoint">The endpoint that is to be customized.</param>
  39. /// <param name="clientRuntime">The client runtime to be customized.</param>
  40. public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
  41. {
  42. throw Fx.Exception.AsError(
  43. new NotSupportedException(SR.ApplyClientBehaviorNotSupportedByBehavior(httpMemoryBehaviorType.Name)));
  44. }
  45. /// <summary>
  46. /// Implements a modification or extension of the service across an endpoint.
  47. /// </summary>
  48. /// <param name="endpoint">The endpoint that exposes the contract.</param>
  49. /// <param name="endpointDispatcher">The endpoint dispatcher to be modified or extended.</param>
  50. public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
  51. {
  52. if (endpoint == null)
  53. {
  54. throw new ArgumentNullException("endpoint");
  55. }
  56. if (endpointDispatcher == null)
  57. {
  58. throw new ArgumentNullException("endpointDispatcher");
  59. }
  60. foreach (OperationDescription operationDescription in endpoint.Contract.Operations)
  61. {
  62. OperationBehaviorAttribute operationBehavior = operationDescription.Behaviors.Find<OperationBehaviorAttribute>();
  63. if (operationBehavior == null)
  64. {
  65. operationDescription.Behaviors.Add(new OperationBehaviorAttribute { AutoDisposeParameters = false });
  66. }
  67. else
  68. {
  69. operationBehavior.AutoDisposeParameters = false;
  70. }
  71. }
  72. }
  73. /// <summary>
  74. /// Confirms that the endpoint meets some intended criteria.
  75. /// </summary>
  76. /// <param name="endpoint">The endpoint to validate.</param>
  77. public void Validate(ServiceEndpoint endpoint)
  78. {
  79. if (endpoint == null)
  80. {
  81. throw Fx.Exception.ArgumentNull("endpoint");
  82. }
  83. }
  84. }
  85. }