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