< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.DataContractSerializerServiceBehavior
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/DataContractSerializerServiceBehavior.cs
Line coverage
42%
Covered lines: 12
Uncovered lines: 16
Coverable lines: 28
Total lines: 85
Line coverage: 42.8%
Branch coverage
100%
Covered branches: 14
Total branches: 14
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/DataContractSerializerServiceBehavior.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.Collections.ObjectModel;
 5using CoreWCF.Channels;
 6using CoreWCF.Description;
 7
 8namespace CoreWCF.Dispatcher
 9{
 10    internal class DataContractSerializerServiceBehavior : IServiceBehavior, IEndpointBehavior
 11    {
 012        internal DataContractSerializerServiceBehavior(bool ignoreExtensionDataObject, int maxItemsInObjectGraph)
 13        {
 014            IgnoreExtensionDataObject = ignoreExtensionDataObject;
 015            MaxItemsInObjectGraph = maxItemsInObjectGraph;
 016        }
 17
 018        public bool IgnoreExtensionDataObject { get; set; }
 19
 020        public int MaxItemsInObjectGraph { get; set; }
 21
 22        void IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase)
 23        {
 024        }
 25
 26        void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Coll
 27        {
 028        }
 29
 30        void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase)
 31        {
 032            ApplySerializationSettings(description, IgnoreExtensionDataObject, MaxItemsInObjectGraph);
 033        }
 34
 35        void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
 36        {
 037        }
 38
 39        void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection paramete
 40        {
 041        }
 42
 43        void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime clientRuntime)
 44        {
 045            ApplySerializationSettings(serviceEndpoint, IgnoreExtensionDataObject, MaxItemsInObjectGraph);
 046        }
 47
 48        void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatc
 49        {
 050            ApplySerializationSettings(serviceEndpoint, IgnoreExtensionDataObject, MaxItemsInObjectGraph);
 051        }
 52
 53        internal static void ApplySerializationSettings(ServiceDescription description, bool ignoreExtensionDataObject, 
 54        {
 243455            foreach (ServiceEndpoint endpoint in description.Endpoints)
 56            {
 64157                if (!endpoint.InternalIsSystemEndpoint(description))
 58                {
 64159                    ApplySerializationSettings(endpoint, ignoreExtensionDataObject, maxItemsInObjectGraph);
 60                }
 61            }
 57662        }
 63
 64        internal static void ApplySerializationSettings(ServiceEndpoint endpoint, bool ignoreExtensionDataObject, int ma
 65        {
 733866            foreach (OperationDescription operation in endpoint.Contract.Operations)
 67            {
 2458268                foreach (IOperationBehavior ob in operation.Behaviors)
 69                {
 926370                    if (ob is DataContractSerializerOperationBehavior behavior)
 71                    {
 297872                        if (!behavior.IgnoreExtensionDataObjectSetExplicit)
 73                        {
 297874                            behavior.ignoreExtensionDataObject = ignoreExtensionDataObject;
 75                        }
 297876                        if (!behavior.MaxItemsInObjectGraphSetExplicit)
 77                        {
 297878                            behavior.maxItemsInObjectGraph = maxItemsInObjectGraph;
 79                        }
 80                    }
 81                }
 82            }
 64183        }
 84    }
 85}