WindowsStreamSecurityElement.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //------------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------------------------
  4. namespace System.ServiceModel.Configuration
  5. {
  6. using System.ComponentModel;
  7. using System.Configuration;
  8. using System.Globalization;
  9. using System.Net.Security;
  10. using System.Text;
  11. using System.ServiceModel.Channels;
  12. public sealed partial class WindowsStreamSecurityElement : BindingElementExtensionElement
  13. {
  14. public WindowsStreamSecurityElement()
  15. {
  16. }
  17. [ConfigurationProperty(ConfigurationStrings.ProtectionLevel, DefaultValue = ConnectionOrientedTransportDefaults.ProtectionLevel)]
  18. [StandardRuntimeEnumValidator(typeof(ProtectionLevel))]
  19. public ProtectionLevel ProtectionLevel
  20. {
  21. get { return (ProtectionLevel)base[ConfigurationStrings.ProtectionLevel]; }
  22. set { base[ConfigurationStrings.ProtectionLevel] = value; }
  23. }
  24. public override void ApplyConfiguration(BindingElement bindingElement)
  25. {
  26. base.ApplyConfiguration(bindingElement);
  27. WindowsStreamSecurityBindingElement windowsBindingElement =
  28. (WindowsStreamSecurityBindingElement)bindingElement;
  29. windowsBindingElement.ProtectionLevel = this.ProtectionLevel;
  30. }
  31. protected internal override BindingElement CreateBindingElement()
  32. {
  33. WindowsStreamSecurityBindingElement windowsBindingElement
  34. = new WindowsStreamSecurityBindingElement();
  35. this.ApplyConfiguration(windowsBindingElement);
  36. return windowsBindingElement;
  37. }
  38. public override Type BindingElementType
  39. {
  40. get { return typeof(WindowsStreamSecurityBindingElement); }
  41. }
  42. public override void CopyFrom(ServiceModelExtensionElement from)
  43. {
  44. base.CopyFrom(from);
  45. WindowsStreamSecurityElement source = (WindowsStreamSecurityElement)from;
  46. #pragma warning suppress 56506 // [....], base.CopyFrom() validates the argument
  47. this.ProtectionLevel = source.ProtectionLevel;
  48. }
  49. protected internal override void InitializeFrom(BindingElement bindingElement)
  50. {
  51. base.InitializeFrom(bindingElement);
  52. WindowsStreamSecurityBindingElement windowsBindingElement
  53. = (WindowsStreamSecurityBindingElement)bindingElement;
  54. SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProtectionLevel, windowsBindingElement.ProtectionLevel);
  55. }
  56. }
  57. }