HttpCookieContainerBindingElement.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel.Channels
  5. {
  6. using System;
  7. using System.ComponentModel;
  8. using System.ServiceModel;
  9. [Obsolete(HttpChannelUtilities.ObsoleteDescriptionStrings.TypeObsoleteUseAllowCookies, false)]
  10. [EditorBrowsable(EditorBrowsableState.Never)]
  11. public class HttpCookieContainerBindingElement : BindingElement
  12. {
  13. [Obsolete(HttpChannelUtilities.ObsoleteDescriptionStrings.TypeObsoleteUseAllowCookies, false)]
  14. [EditorBrowsable(EditorBrowsableState.Never)]
  15. public HttpCookieContainerBindingElement()
  16. {
  17. }
  18. [Obsolete(HttpChannelUtilities.ObsoleteDescriptionStrings.TypeObsoleteUseAllowCookies, false)]
  19. [EditorBrowsable(EditorBrowsableState.Never)]
  20. protected HttpCookieContainerBindingElement(HttpCookieContainerBindingElement elementToBeCloned) : base(elementToBeCloned)
  21. {
  22. }
  23. [EditorBrowsable(EditorBrowsableState.Never)]
  24. public override BindingElement Clone()
  25. {
  26. return new HttpCookieContainerBindingElement(this);
  27. }
  28. [EditorBrowsable(EditorBrowsableState.Never)]
  29. public override IChannelFactory<TChannel> BuildChannelFactory<TChannel>(BindingContext context)
  30. {
  31. if (context == null)
  32. {
  33. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("context"));
  34. }
  35. if (!context.Binding.Scheme.Equals("http", StringComparison.OrdinalIgnoreCase) &&
  36. !context.Binding.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase))
  37. {
  38. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
  39. new InvalidOperationException(
  40. SR.GetString(SR.CookieContainerBindingElementNeedsHttp, typeof(HttpCookieContainerBindingElement))));
  41. }
  42. #pragma warning suppress 56506 // BindingContext.BindingParameters should never be null
  43. context.BindingParameters.Add(this);
  44. #pragma warning restore 56506
  45. return context.BuildInnerChannelFactory<TChannel>();
  46. }
  47. [EditorBrowsable(EditorBrowsableState.Never)]
  48. public override T GetProperty<T>(BindingContext context)
  49. {
  50. if (context == null)
  51. {
  52. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
  53. }
  54. return context.GetInnerProperty<T>();
  55. }
  56. }
  57. }