| | | 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 | | using System.ComponentModel; |
| | | 5 | | using System.Xml; |
| | | 6 | | using CoreWCF.Channels; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF |
| | | 9 | | { |
| | | 10 | | public class UnixDomainSocketBinding : Binding |
| | | 11 | | { |
| | | 12 | | // private BindingElements |
| | | 13 | | private UnixDomainSocketTransportBindingElement _transport; |
| | | 14 | | private BinaryMessageEncodingBindingElement _encoding; |
| | 6 | 15 | | private UnixDomainSocketSecurity _security = new UnixDomainSocketSecurity(); |
| | | 16 | | |
| | 18 | 17 | | public UnixDomainSocketBinding() { Initialize(); } |
| | | 18 | | public UnixDomainSocketBinding(UnixDomainSocketSecurityMode securityMode) |
| | 3 | 19 | | : this() |
| | | 20 | | { |
| | 3 | 21 | | _security.Mode = securityMode; |
| | 3 | 22 | | } |
| | | 23 | | |
| | | 24 | | public TransferMode TransferMode |
| | | 25 | | { |
| | 0 | 26 | | get { return _transport.TransferMode; } |
| | 0 | 27 | | set { _transport.TransferMode = value; } |
| | | 28 | | } |
| | | 29 | | |
| | | 30 | | public HostNameComparisonMode HostNameComparisonMode |
| | | 31 | | { |
| | 0 | 32 | | get { return _transport.HostNameComparisonMode; } |
| | 0 | 33 | | set { _transport.HostNameComparisonMode = value; } |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | public long MaxReceivedMessageSize |
| | | 37 | | { |
| | 0 | 38 | | get { return _transport.MaxReceivedMessageSize; } |
| | 0 | 39 | | set { _transport.MaxReceivedMessageSize = value; } |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | public XmlDictionaryReaderQuotas ReaderQuotas |
| | | 43 | | { |
| | 0 | 44 | | get { return _encoding.ReaderQuotas; } |
| | | 45 | | set |
| | | 46 | | { |
| | 0 | 47 | | if (value == null) |
| | | 48 | | { |
| | 0 | 49 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); |
| | | 50 | | } |
| | | 51 | | |
| | 0 | 52 | | value.CopyTo(_encoding.ReaderQuotas); |
| | 0 | 53 | | } |
| | | 54 | | } |
| | | 55 | | |
| | 0 | 56 | | public override string Scheme { get { return _transport.Scheme; } } |
| | | 57 | | |
| | | 58 | | public EnvelopeVersion EnvelopeVersion |
| | | 59 | | { |
| | 0 | 60 | | get { return EnvelopeVersion.Soap12; } |
| | | 61 | | } |
| | | 62 | | |
| | | 63 | | public UnixDomainSocketSecurity Security |
| | | 64 | | { |
| | 2 | 65 | | get { return _security; } |
| | | 66 | | set |
| | | 67 | | { |
| | 3 | 68 | | _security = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); |
| | 3 | 69 | | } |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | private void Initialize() |
| | | 73 | | { |
| | 6 | 74 | | _transport = new UnixDomainSocketTransportBindingElement(); |
| | 6 | 75 | | _encoding = new BinaryMessageEncodingBindingElement(); |
| | 6 | 76 | | } |
| | | 77 | | |
| | | 78 | | public override BindingElementCollection CreateBindingElements() |
| | | 79 | | { |
| | | 80 | | // return collection of BindingElements |
| | 50 | 81 | | BindingElementCollection bindingElements = new BindingElementCollection |
| | 50 | 82 | | { |
| | 50 | 83 | | // order of BindingElements is important |
| | 50 | 84 | | // add encoding |
| | 50 | 85 | | _encoding |
| | 50 | 86 | | }; |
| | | 87 | | |
| | | 88 | | // add transport security |
| | 50 | 89 | | BindingElement transportSecurity = CreateTransportSecurity(); |
| | 47 | 90 | | if (transportSecurity != null) |
| | | 91 | | { |
| | 32 | 92 | | bindingElements.Add(transportSecurity); |
| | | 93 | | } |
| | 47 | 94 | | bindingElements.Add(_transport); |
| | 47 | 95 | | return bindingElements.Clone(); |
| | | 96 | | } |
| | | 97 | | |
| | | 98 | | private BindingElement CreateTransportSecurity() |
| | | 99 | | { |
| | 50 | 100 | | return _security.CreateTransportSecurity(); |
| | | 101 | | } |
| | | 102 | | } |
| | | 103 | | } |