< Summary

Information
Class: Ice.Internal.DefaultsAndOverrides
Assembly: Ice
File(s): /_/csharp/src/Ice/Internal/DefaultsAndOverrides.cs
Tag: 99_23991109993
Line coverage
73%
Covered lines: 31
Uncovered lines: 11
Coverable lines: 42
Total lines: 107
Line coverage: 73.8%
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%38.142673.81%

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                throw new Ice.InitializationException(
 030                    "invalid IP address set for Ice.Default.SourceAddress: '" + val + "'");
 31        }
 32        else
 33        {
 134            defaultSourceAddress = null;
 35        }
 36
 137        val = properties.getIceProperty("Ice.Override.Compress");
 138        if (val.Length > 0)
 39        {
 140            overrideCompress = properties.getIcePropertyAsInt("Ice.Override.Compress") > 0;
 141            if (!BZip2.isLoaded(logger) && overrideCompress.Value)
 42            {
 043                Console.Error.WriteLine("warning: BZip2 library not found, Ice.Override.Compress ignored.");
 044                overrideCompress = null;
 45            }
 46        }
 47        else
 48        {
 149            overrideCompress = BZip2.isLoaded(logger) ? null : false;
 50        }
 51
 152        defaultCollocationOptimization =
 153            properties.getIcePropertyAsInt("Ice.Default.CollocationOptimized") > 0;
 54
 155        val = properties.getIceProperty("Ice.Default.EndpointSelection");
 156        if (val == "Random")
 57        {
 158            defaultEndpointSelection = Ice.EndpointSelectionType.Random;
 59        }
 060        else if (val == "Ordered")
 61        {
 062            defaultEndpointSelection = Ice.EndpointSelectionType.Ordered;
 63        }
 64        else
 65        {
 066            throw new ParseException(
 067                $"illegal value '{val}' in property Ice.Default.EndpointSelection; expected 'Random' or 'Ordered'");
 68        }
 69
 70        {
 171            int value = properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout");
 172            if (value < -1)
 73            {
 074                throw new InitializationException($"invalid value for Ice.Default.LocatorCacheTimeout: {value}");
 75            }
 176            defaultLocatorCacheTimeout = TimeSpan.FromSeconds(value);
 77        }
 78
 79        {
 180            int value = properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout");
 181            if (value < 1 && value != -1)
 82            {
 083                throw new InitializationException($"invalid value for Ice.Default.InvocationTimeout: {value}");
 84            }
 185            defaultInvocationTimeout = TimeSpan.FromMilliseconds(value);
 86        }
 87
 188        val = properties.getIceProperty("Ice.Default.EncodingVersion");
 189        defaultEncoding = Protocol.stringToEncodingVersion(val);
 190        Protocol.checkSupportedEncoding(defaultEncoding);
 91
 192        bool slicedFormat = properties.getIcePropertyAsInt("Ice.Default.SlicedFormat") > 0;
 193        defaultFormat = slicedFormat ? FormatType.SlicedFormat : FormatType.CompactFormat;
 194    }
 95
 96    public string defaultHost;
 97    public EndPoint defaultSourceAddress;
 98    public string defaultProtocol;
 99    public bool defaultCollocationOptimization;
 100    public Ice.EndpointSelectionType defaultEndpointSelection;
 101    public TimeSpan defaultLocatorCacheTimeout;
 102    public TimeSpan defaultInvocationTimeout;
 103    public Ice.EncodingVersion defaultEncoding;
 104    public Ice.FormatType defaultFormat;
 105
 106    public bool? overrideCompress;
 107}