| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace CoreWCF.Channels |
| | | 5 | | { |
| | | 6 | | internal static class ChannelBindingMessagePropertyHelper |
| | | 7 | | { |
| | | 8 | | internal static bool TryGet(Message message, out ChannelBindingMessageProperty property) |
| | | 9 | | { |
| | 0 | 10 | | if (message == null) |
| | | 11 | | { |
| | 0 | 12 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(message)); |
| | | 13 | | } |
| | | 14 | | |
| | 0 | 15 | | return TryGet(message.Properties, out property); |
| | | 16 | | } |
| | | 17 | | |
| | | 18 | | internal static bool TryGet(MessageProperties properties, out ChannelBindingMessageProperty property) |
| | | 19 | | { |
| | 0 | 20 | | if (properties == null) |
| | | 21 | | { |
| | 0 | 22 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(properties)); |
| | | 23 | | } |
| | | 24 | | |
| | 0 | 25 | | property = null; |
| | | 26 | | |
| | 0 | 27 | | if (properties.TryGetValue(ChannelBindingMessageProperty.Name, out object value)) |
| | | 28 | | { |
| | 0 | 29 | | property = value as ChannelBindingMessageProperty; |
| | 0 | 30 | | return property != null; |
| | | 31 | | } |
| | | 32 | | |
| | 0 | 33 | | return false; |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | internal static void AddTo(this ChannelBindingMessageProperty channelBindingProperty, Message message) |
| | | 37 | | { |
| | 0 | 38 | | if (message == null) |
| | | 39 | | { |
| | 0 | 40 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(message)); |
| | | 41 | | } |
| | | 42 | | |
| | 0 | 43 | | channelBindingProperty.AddTo(message.Properties); |
| | 0 | 44 | | } |
| | | 45 | | |
| | | 46 | | internal static void AddTo(this ChannelBindingMessageProperty channelBindingProperty, MessageProperties properti |
| | | 47 | | { |
| | | 48 | | // Throws if disposed |
| | 0 | 49 | | System.Security.Authentication.ExtendedProtection.ChannelBinding dummy = channelBindingProperty.ChannelBindi |
| | 0 | 50 | | if (properties == null) |
| | | 51 | | { |
| | 0 | 52 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(properties)); |
| | | 53 | | } |
| | | 54 | | |
| | 0 | 55 | | properties.Add(ChannelBindingMessageProperty.Name, channelBindingProperty); |
| | 0 | 56 | | } |
| | | 57 | | } |
| | | 58 | | } |