1 //------------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------------------------
5 namespace System.ServiceModel.Configuration
7 using System.ComponentModel;
8 using System.Configuration;
9 using System.Globalization;
10 using System.Net.Security;
12 using System.ServiceModel.Channels;
14 public sealed partial class WindowsStreamSecurityElement : BindingElementExtensionElement
16 public WindowsStreamSecurityElement()
20 [ConfigurationProperty(ConfigurationStrings.ProtectionLevel, DefaultValue = ConnectionOrientedTransportDefaults.ProtectionLevel)]
21 [StandardRuntimeEnumValidator(typeof(ProtectionLevel))]
22 public ProtectionLevel ProtectionLevel
24 get { return (ProtectionLevel)base[ConfigurationStrings.ProtectionLevel]; }
25 set { base[ConfigurationStrings.ProtectionLevel] = value; }
28 public override void ApplyConfiguration(BindingElement bindingElement)
30 base.ApplyConfiguration(bindingElement);
31 WindowsStreamSecurityBindingElement windowsBindingElement =
32 (WindowsStreamSecurityBindingElement)bindingElement;
33 windowsBindingElement.ProtectionLevel = this.ProtectionLevel;
36 protected internal override BindingElement CreateBindingElement()
38 WindowsStreamSecurityBindingElement windowsBindingElement
39 = new WindowsStreamSecurityBindingElement();
41 this.ApplyConfiguration(windowsBindingElement);
42 return windowsBindingElement;
45 public override Type BindingElementType
47 get { return typeof(WindowsStreamSecurityBindingElement); }
50 public override void CopyFrom(ServiceModelExtensionElement from)
54 WindowsStreamSecurityElement source = (WindowsStreamSecurityElement)from;
55 #pragma warning suppress 56506 // Microsoft, base.CopyFrom() validates the argument
56 this.ProtectionLevel = source.ProtectionLevel;
59 protected internal override void InitializeFrom(BindingElement bindingElement)
61 base.InitializeFrom(bindingElement);
62 WindowsStreamSecurityBindingElement windowsBindingElement
63 = (WindowsStreamSecurityBindingElement)bindingElement;
64 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProtectionLevel, windowsBindingElement.ProtectionLevel);