WSFederationHttpBindingElement.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //------------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------------------------
  4. namespace System.ServiceModel.Configuration
  5. {
  6. using System.Configuration;
  7. using System.ServiceModel;
  8. using System.Globalization;
  9. using System.ServiceModel.Security;
  10. using System.ComponentModel;
  11. using System.Text;
  12. using System.ServiceModel.Channels;
  13. public partial class WSFederationHttpBindingElement : WSHttpBindingBaseElement
  14. {
  15. public WSFederationHttpBindingElement(string name)
  16. : base(name)
  17. {
  18. }
  19. public WSFederationHttpBindingElement()
  20. : this(null)
  21. {
  22. }
  23. protected override Type BindingElementType
  24. {
  25. get { return typeof(WSFederationHttpBinding); }
  26. }
  27. [ConfigurationProperty(ConfigurationStrings.PrivacyNoticeAt, DefaultValue = null)]
  28. public Uri PrivacyNoticeAt
  29. {
  30. get { return (Uri) base[ConfigurationStrings.PrivacyNoticeAt]; }
  31. set { base[ConfigurationStrings.PrivacyNoticeAt] = value; }
  32. }
  33. [ConfigurationProperty(ConfigurationStrings.PrivacyNoticeVersion, DefaultValue = 0)]
  34. [IntegerValidator(MinValue = 0)]
  35. public int PrivacyNoticeVersion
  36. {
  37. get { return (int) base[ConfigurationStrings.PrivacyNoticeVersion]; }
  38. set { base[ConfigurationStrings.PrivacyNoticeVersion] = value; }
  39. }
  40. [ConfigurationProperty(ConfigurationStrings.Security)]
  41. public WSFederationHttpSecurityElement Security
  42. {
  43. get { return (WSFederationHttpSecurityElement)base[ConfigurationStrings.Security]; }
  44. }
  45. protected internal override void InitializeFrom(Binding binding)
  46. {
  47. base.InitializeFrom(binding);
  48. WSFederationHttpBinding wspBinding = (WSFederationHttpBinding)binding;
  49. if ( wspBinding.PrivacyNoticeAt != null )
  50. {
  51. SetPropertyValueIfNotDefaultValue(ConfigurationStrings.PrivacyNoticeAt, wspBinding.PrivacyNoticeAt);
  52. SetPropertyValueIfNotDefaultValue(ConfigurationStrings.PrivacyNoticeVersion, wspBinding.PrivacyNoticeVersion);
  53. }
  54. this.Security.InitializeFrom(wspBinding.Security);
  55. }
  56. protected override void OnApplyConfiguration(Binding binding)
  57. {
  58. base.OnApplyConfiguration(binding);
  59. WSFederationHttpBinding wspBinding = (WSFederationHttpBinding)binding;
  60. if (this.PrivacyNoticeAt != null)
  61. {
  62. wspBinding.PrivacyNoticeAt = this.PrivacyNoticeAt;
  63. wspBinding.PrivacyNoticeVersion = this.PrivacyNoticeVersion;
  64. }
  65. this.Security.ApplyConfiguration(wspBinding.Security);
  66. }
  67. }
  68. }