< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.NetNamedPipeBinding
Assembly: CoreWCF.NetNamedPipe
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetNamedPipe/src/CoreWCF/NetNamedPipeBinding.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 47
Coverable lines: 47
Total lines: 165
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%110%
.ctor(...)100%110%
.ctor(...)100%110%
Initialize()100%110%
CreateBindingElements()0%220%
CreateTransportSecurity()0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetNamedPipe/src/CoreWCF/NetNamedPipeBinding.cs

#LineLine coverage
 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
 4using System.ComponentModel;
 5using System.Runtime.Versioning;
 6using System.Xml;
 7using CoreWCF.Channels;
 8
 9namespace CoreWCF
 10{
 11    [SupportedOSPlatform("windows")]
 12    public class NetNamedPipeBinding : Binding
 13    {
 14        // private BindingElements
 15        //TransactionFlowBindingElement context;
 16        private BinaryMessageEncodingBindingElement _encoding;
 17        private NamedPipeTransportBindingElement _namedPipe;
 018        private NetNamedPipeSecurity _security = new NetNamedPipeSecurity();
 19
 20        public NetNamedPipeBinding()
 021            : base()
 22        {
 023            Initialize();
 024        }
 25
 26        public NetNamedPipeBinding(NetNamedPipeSecurityMode securityMode)
 027            : this()
 28        {
 029            _security.Mode = securityMode;
 030        }
 31
 32        private NetNamedPipeBinding(NetNamedPipeSecurity security)
 033            : this()
 34        {
 035            _security = security;
 036        }
 37
 38        // The following properties have moved to NamedPipeListenOptions as that's the
 39        // equivalent of the shared listeners from WCF
 40        // ConnectionBufferSize
 41        // HostNameComparisonMode
 42        // MaxPendingAccepts
 43
 44        //[DefaultValue(TransactionFlowDefaults.Transactions)]
 45        //public bool TransactionFlow
 46        //{
 47        //    get { return context.Transactions; }
 48        //    set { context.Transactions = value; }
 49        //}
 50
 51        //public TransactionProtocol TransactionProtocol
 52        //{
 53        //    get { return this.context.TransactionProtocol; }
 54        //    set { this.context.TransactionProtocol = value; }
 55        //}
 56
 57        [DefaultValue(ConnectionOrientedTransportDefaults.TransferMode)]
 58        public TransferMode TransferMode
 59        {
 060            get { return _namedPipe.TransferMode; }
 061            set { _namedPipe.TransferMode = value; }
 62        }
 63
 64        [DefaultValue(TransportDefaults.MaxBufferPoolSize)]
 65        public long MaxBufferPoolSize
 66        {
 067            get { return _namedPipe.MaxBufferPoolSize; }
 68            set
 69            {
 070                _namedPipe.MaxBufferPoolSize = value;
 071            }
 72        }
 73
 74        [DefaultValue(TransportDefaults.MaxBufferSize)]
 75        public int MaxBufferSize
 76        {
 077            get { return _namedPipe.MaxBufferSize; }
 078            set { _namedPipe.MaxBufferSize = value; }
 79        }
 80
 81        public int MaxConnections
 82        {
 083            get { return _namedPipe.MaxPendingConnections; }
 84            set
 85            {
 086                _namedPipe.MaxPendingConnections = value;
 087            }
 88        }
 89
 90        [DefaultValue(TransportDefaults.MaxReceivedMessageSize)]
 91        public long MaxReceivedMessageSize
 92        {
 093            get { return _namedPipe.MaxReceivedMessageSize; }
 094            set { _namedPipe.MaxReceivedMessageSize = value; }
 95        }
 96
 97        public XmlDictionaryReaderQuotas ReaderQuotas
 98        {
 099            get { return _encoding.ReaderQuotas; }
 100            set
 101            {
 0102                if (value == null)
 0103                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 0104                value.CopyTo(_encoding.ReaderQuotas);
 0105            }
 106        }
 107
 0108        public override string Scheme { get { return _namedPipe.Scheme; } }
 109
 110        public EnvelopeVersion EnvelopeVersion
 111        {
 0112            get { return EnvelopeVersion.Soap12; }
 113        }
 114
 115        public NetNamedPipeSecurity Security
 116        {
 0117            get { return _security; }
 118            set
 119            {
 0120                if (value == null)
 0121                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
 0122                _security = value;
 0123            }
 124        }
 125
 126        private void Initialize()
 127        {
 0128            _namedPipe = new NamedPipeTransportBindingElement();
 0129            _encoding = new BinaryMessageEncodingBindingElement();
 130            //context = GetDefaultTransactionFlowBindingElement();
 0131        }
 132
 133        public override BindingElementCollection CreateBindingElements()
 134        {   // return collection of BindingElements
 0135            BindingElementCollection bindingElements = new BindingElementCollection();
 136            // order of BindingElements is important
 137            // add context
 138            //bindingElements.Add(context);
 139            // add encoding
 0140            bindingElements.Add(_encoding);
 141            // add transport security
 0142            WindowsStreamSecurityBindingElement transportSecurity = CreateTransportSecurity();
 0143            if (transportSecurity != null)
 144            {
 0145                bindingElements.Add(transportSecurity);
 146            }
 147            // add transport (named pipes)
 0148            bindingElements.Add(_namedPipe);
 149
 0150            return bindingElements.Clone();
 151        }
 152
 153        private WindowsStreamSecurityBindingElement CreateTransportSecurity()
 154        {
 0155            if (_security.Mode == NetNamedPipeSecurityMode.Transport)
 156            {
 0157                return _security.CreateTransportSecurity();
 158            }
 159            else
 160            {
 0161                return null;
 162            }
 163        }
 164    }
 165}