< Summary

Information
Class: Ice.Internal.DefaultsAndOverrides
Assembly: Ice
File(s): /_/csharp/src/Ice/Internal/DefaultsAndOverrides.cs
Tag: 91_21789722663
Line coverage
72%
Covered lines: 31
Uncovered lines: 12
Coverable lines: 43
Total lines: 110
Line coverage: 72%
Branch coverage
53%
Covered branches: 14
Total branches: 26
Branch coverage: 53.8%
Method coverage
100%
Covered methods: 1
Total methods: 1
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)53.85%40.72672.09%

File(s)

/_/csharp/src/Ice/Internal/DefaultsAndOverrides.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Net;
 4
 5namespace Ice.Internal;
 6
 7public sealed class DefaultsAndOverrides
 8{
 19    internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger)
 10    {
 11        string val;
 12
 113        defaultProtocol = properties.getIceProperty("Ice.Default.Protocol");
 14
 115        val = properties.getIceProperty("Ice.Default.Host");
 116        if (val.Length != 0)
 17        {
 118            defaultHost = val;
 19        }
 20        else
 21        {
 122            defaultHost = null;
 23        }
 24
 125        val = properties.getIceProperty("Ice.Default.SourceAddress");
 126        if (val.Length > 0)
 27        {
 028            defaultSourceAddress = Network.getNumericAddress(val);
 029            if (defaultSourceAddress == null)
 30            {
 031                throw new Ice.InitializationException("invalid IP address set for Ice.Default.SourceAddress: `" +
 032                                                      val + "'");
 33            }
 34        }
 35        else
 36        {
 137            defaultSourceAddress = null;
 38        }
 39
 140        val = properties.getIceProperty("Ice.Override.Compress");
 141        if (val.Length > 0)
 42        {
 143            overrideCompress = properties.getIcePropertyAsInt("Ice.Override.Compress") > 0;
 144            if (!BZip2.isLoaded(logger) && overrideCompress.Value)
 45            {
 046                Console.Error.WriteLine("warning: BZip2 library not found, Ice.Override.Compress ignored.");
 047                overrideCompress = null;
 48            }
 49        }
 50        else
 51        {
 152            overrideCompress = BZip2.isLoaded(logger) ? null : false;
 53        }
 54
 155        defaultCollocationOptimization =
 156            properties.getIcePropertyAsInt("Ice.Default.CollocationOptimized") > 0;
 57
 158        val = properties.getIceProperty("Ice.Default.EndpointSelection");
 159        if (val == "Random")
 60        {
 161            defaultEndpointSelection = Ice.EndpointSelectionType.Random;
 62        }
 063        else if (val == "Ordered")
 64        {
 065            defaultEndpointSelection = Ice.EndpointSelectionType.Ordered;
 66        }
 67        else
 68        {
 069            throw new ParseException(
 070                $"illegal value '{val}' in property Ice.Default.EndpointSelection; expected 'Random' or 'Ordered'");
 71        }
 72
 73        {
 174            int value = properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout");
 175            if (value < -1)
 76            {
 077                throw new InitializationException($"invalid value for Ice.Default.LocatorCacheTimeout: {value}");
 78            }
 179            defaultLocatorCacheTimeout = TimeSpan.FromSeconds(value);
 80        }
 81
 82        {
 183            int value = properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout");
 184            if (value < 1 && value != -1)
 85            {
 086                throw new InitializationException($"invalid value for Ice.Default.InvocationTimeout: {value}");
 87            }
 188            defaultInvocationTimeout = TimeSpan.FromMilliseconds(value);
 89        }
 90
 191        val = properties.getIceProperty("Ice.Default.EncodingVersion");
 192        defaultEncoding = Protocol.stringToEncodingVersion(val);
 193        Protocol.checkSupportedEncoding(defaultEncoding);
 94
 195        bool slicedFormat = properties.getIcePropertyAsInt("Ice.Default.SlicedFormat") > 0;
 196        defaultFormat = slicedFormat ? FormatType.SlicedFormat : FormatType.CompactFormat;
 197    }
 98
 99    public string defaultHost;
 100    public EndPoint defaultSourceAddress;
 101    public string defaultProtocol;
 102    public bool defaultCollocationOptimization;
 103    public Ice.EndpointSelectionType defaultEndpointSelection;
 104    public TimeSpan defaultLocatorCacheTimeout;
 105    public TimeSpan defaultInvocationTimeout;
 106    public Ice.EncodingVersion defaultEncoding;
 107    public Ice.FormatType defaultFormat;
 108
 109    public bool? overrideCompress;
 110}