< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.AddressHeaderCollectionElement
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/AddressHeaderCollectionElement.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 30
Coverable lines: 30
Total lines: 86
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 14
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%
Copy(...)0%440%
DeserializeElement(...)100%110%
DeserializeElementCore(...)100%110%
SerializeToXmlElement(...)0%660%
InitializeFrom(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/AddressHeaderCollectionElement.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.Configuration;
 5using System.Xml;
 6using CoreWCF.Channels;
 7
 8namespace CoreWCF.Configuration
 9{
 10    public sealed class AddressHeaderCollectionElement : ServiceModelConfigurationElement
 11    {
 012        public AddressHeaderCollectionElement()
 13        {
 014        }
 15
 16        internal void Copy(AddressHeaderCollectionElement source)
 17        {
 018            if (source == null)
 19            {
 020                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(source));
 21            }
 22
 023            PropertyInformationCollection properties = source.ElementInformation.Properties;
 024            if (properties[ConfigurationStrings.Headers].ValueOrigin != PropertyValueOrigin.Default)
 25            {
 026                Headers = source.Headers;
 27            }
 028        }
 29
 30        [ConfigurationProperty(ConfigurationStrings.Headers, DefaultValue = null)]
 31        public AddressHeaderCollection Headers
 32        {
 33            get
 34            {
 035                AddressHeaderCollection retVal = (AddressHeaderCollection)base[ConfigurationStrings.Headers];
 036                if (null == retVal)
 37                {
 038                    retVal = new AddressHeaderCollection();
 39                }
 040                return retVal;
 41            }
 42            set
 43            {
 044                if (value == null)
 45                {
 046                    value = new AddressHeaderCollection();
 47                }
 048                base[ConfigurationStrings.Headers] = value;
 049            }
 50        }
 51
 52
 53        protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
 54        {
 055            DeserializeElementCore(XmlDictionaryReader.CreateDictionaryReader(reader));
 056        }
 57
 58        private void DeserializeElementCore(XmlDictionaryReader reader)
 59        {
 060            Headers = new AddressHeaderCollection(new[] { new XmlElementBackedAddressHeader(reader) });
 061        }
 62
 63        protected override bool SerializeToXmlElement(XmlWriter writer, string elementName)
 64        {
 065            bool dataToWrite = Headers.Count != 0;
 066            if (dataToWrite && writer != null)
 67            {
 068                writer.WriteStartElement(elementName);
 69
 070                XmlDictionaryWriter dictionaryWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer);
 071                foreach (AddressHeader header in Headers)
 72                {
 073                    header.WriteAddressHeader(dictionaryWriter);
 74                }
 75
 076                writer.WriteEndElement();
 77            }
 078            return dataToWrite;
 79        }
 80
 81        internal void InitializeFrom(AddressHeaderCollection headers)
 82        {
 083            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Headers, headers);
 084        }
 85    }
 86}