< Summary

Information
Class: Ice.Internal.ReferenceFactory
Assembly: Ice
File(s): /home/runner/work/ice/ice/csharp/src/Ice/Internal/ReferenceFactory.cs
Tag: 71_18251537082
Line coverage
83%
Covered lines: 280
Uncovered lines: 56
Coverable lines: 336
Total lines: 779
Line coverage: 83.3%
Branch coverage
74%
Covered branches: 147
Total branches: 197
Branch coverage: 74.6%
Method coverage
100%
Covered methods: 12
Total methods: 12
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
create(...)25%4.01490.91%
create(...)25%4.01490.91%
create(...)50%6.01692.86%
copy(...)25%4.25475%
create(...)80.31%289.3212778.41%
create(...)55.56%20.31880.77%
setDefaultRouter(...)75%4.07483.33%
getDefaultRouter()100%11100%
setDefaultLocator(...)75%4.07483.33%
getDefaultLocator()100%11100%
.ctor(...)100%11100%
create(...)88.46%26.532690.79%

File(s)

/home/runner/work/ice/ice/csharp/src/Ice/Internal/ReferenceFactory.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Diagnostics;
 4using System.Text;
 5using System.Text.RegularExpressions;
 6
 7namespace Ice.Internal;
 8
 9internal class ReferenceFactory
 10{
 11    internal Reference
 12    create(Ice.Identity ident, string facet, Reference tmpl, EndpointI[] endpoints)
 13    {
 114        if (ident.name.Length == 0 && ident.category.Length == 0)
 15        {
 016            return null;
 17        }
 18
 119        return create(
 120            ident,
 121            facet,
 122            tmpl.getMode(),
 123            tmpl.getProtocol(),
 124            tmpl.getEncoding(),
 125            endpoints,
 126            null,
 127            null);
 28    }
 29
 30    internal Reference
 31    create(Ice.Identity ident, string facet, Reference tmpl, string adapterId)
 32    {
 133        if (ident.name.Length == 0 && ident.category.Length == 0)
 34        {
 035            return null;
 36        }
 37
 38        //
 39        // Create new reference
 40        //
 141        return create(
 142            ident,
 143            facet,
 144            tmpl.getMode(),
 145            tmpl.getProtocol(),
 146            tmpl.getEncoding(),
 147            null,
 148            adapterId,
 149            null);
 50    }
 51
 52    internal Reference create(Ice.Identity ident, Ice.ConnectionI connection)
 53    {
 154        if (ident.name.Length == 0 && ident.category.Length == 0)
 55        {
 056            return null;
 57        }
 58
 59        //
 60        // Create new reference
 61        //
 162        return new FixedReference(
 163            _instance,
 164            _communicator,
 165            ident,
 166            "", // Facet
 167            connection.endpoint().datagram() ? Reference.Mode.ModeDatagram : Reference.Mode.ModeTwoway,
 168            compress: null,
 169            Ice.Util.Protocol_1_0,
 170            _instance.defaultsAndOverrides().defaultEncoding,
 171            connection,
 172            TimeSpan.FromMilliseconds(-1),
 173            null);
 74    }
 75
 76    internal Reference copy(Reference r)
 77    {
 178        Ice.Identity ident = r.getIdentity();
 179        if (ident.name.Length == 0 && ident.category.Length == 0)
 80        {
 081            return null;
 82        }
 183        return r.Clone();
 84    }
 85
 86    internal Reference create(string s, string propertyPrefix)
 87    {
 188        if (s.Length == 0)
 89        {
 190            return null;
 91        }
 92
 93        const string delim = " \t\n\r";
 94
 95        int beg;
 196        int end = 0;
 97
 198        beg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end);
 199        if (beg == -1)
 100        {
 0101            throw new ParseException($"no non-whitespace characters found in proxy string '{s}'");
 102        }
 103
 1104        end = Ice.UtilInternal.StringUtil.checkQuote(s, beg);
 105
 106        //
 107        // Extract the identity, which may be enclosed in single
 108        // or double quotation marks.
 109        //
 110        string idstr;
 1111        if (end == -1)
 112        {
 1113            throw new ParseException($"mismatched quotes around identity in proxy string '{s}'");
 114        }
 1115        else if (end == 0)
 116        {
 1117            end = Ice.UtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg);
 1118            if (end == -1)
 119            {
 1120                end = s.Length;
 121            }
 1122            idstr = s[beg..end];
 123        }
 124        else
 125        {
 1126            beg++; // Skip leading quote
 1127            idstr = s[beg..end];
 1128            end++; // Skip trailing quote
 129        }
 130
 1131        if (beg == end)
 132        {
 0133            throw new ParseException($"no identity in proxy string '{s}'");
 134        }
 135
 136        //
 137        // Parsing the identity may raise ParseException.
 138        //
 1139        Ice.Identity ident = Ice.Util.stringToIdentity(idstr);
 140
 1141        if (ident.name.Length == 0)
 142        {
 143            //
 144            // An identity with an empty name and a non-empty
 145            // category is illegal.
 146            //
 1147            if (ident.category.Length > 0)
 148            {
 0149                throw new ParseException("The category of a null Ice object identity must be empty.");
 150            }
 151            //
 152            // Treat a stringified proxy containing two double
 153            // quotes ("") the same as an empty string, i.e.,
 154            // a null proxy, but only if nothing follows the
 155            // quotes.
 156            //
 1157            else if (Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
 158            {
 1159                throw new ParseException($"invalid characters after identity in proxy string '{s}'");
 160            }
 161            else
 162            {
 1163                return null;
 164            }
 165        }
 166
 1167        string facet = "";
 1168        Reference.Mode mode = Reference.Mode.ModeTwoway;
 1169        Ice.EncodingVersion encoding = _instance.defaultsAndOverrides().defaultEncoding;
 1170        Ice.ProtocolVersion protocol = Ice.Util.Protocol_1_0;
 171        while (true)
 172        {
 1173            beg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end);
 1174            if (beg == -1)
 175            {
 176                break;
 177            }
 178
 1179            if (s[beg] == ':' || s[beg] == '@')
 180            {
 181                break;
 182            }
 183
 1184            end = Ice.UtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg);
 1185            if (end == -1)
 186            {
 1187                end = s.Length;
 188            }
 189
 1190            if (beg == end)
 191            {
 192                break;
 193            }
 194
 1195            string option = s[beg..end];
 1196            if (option.Length != 2 || option[0] != '-')
 197            {
 1198                throw new ParseException($"expected a proxy option but found '{option}' in proxy string '{s}'");
 199            }
 200
 201            //
 202            // Check for the presence of an option argument. The
 203            // argument may be enclosed in single or double
 204            // quotation marks.
 205            //
 1206            string argument = null;
 1207            int argumentBeg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end);
 1208            if (argumentBeg != -1)
 209            {
 1210                char ch = s[argumentBeg];
 1211                if (ch != '@' && ch != ':' && ch != '-')
 212                {
 1213                    beg = argumentBeg;
 1214                    end = Ice.UtilInternal.StringUtil.checkQuote(s, beg);
 1215                    if (end == -1)
 216                    {
 1217                        throw new ParseException(
 1218                            $"mismatched quotes around value for {option} option in proxy string '{s}'");
 219                    }
 1220                    else if (end == 0)
 221                    {
 1222                        end = Ice.UtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg);
 1223                        if (end == -1)
 224                        {
 1225                            end = s.Length;
 226                        }
 1227                        argument = s[beg..end];
 228                    }
 229                    else
 230                    {
 1231                        beg++; // Skip leading quote
 1232                        argument = s[beg..end];
 1233                        end++; // Skip trailing quote
 234                    }
 235                }
 236            }
 237
 238            //
 239            // If any new options are added here,
 240            // Ice.Internal::Reference::toString() and its derived classes must be updated as well.
 241            //
 1242            switch (option[1])
 243            {
 244                case 'f':
 245                {
 1246                    if (argument == null)
 247                    {
 0248                        throw new ParseException($"no argument provided for -f option in proxy string '{s}'");
 249                    }
 250
 251                    try
 252                    {
 1253                        facet = Ice.UtilInternal.StringUtil.unescapeString(argument, 0, argument.Length, "");
 1254                    }
 0255                    catch (ArgumentException argEx)
 256                    {
 0257                        throw new ParseException($"invalid facet in proxy string '{s}'", argEx);
 258                    }
 259                    break;
 260                }
 261
 262                case 't':
 263                {
 1264                    if (argument != null)
 265                    {
 0266                        throw new ParseException(
 0267                            $"unexpected argument '{argument}' provided for -t option in proxy string '{s}'");
 268                    }
 1269                    mode = Reference.Mode.ModeTwoway;
 1270                    break;
 271                }
 272
 273                case 'o':
 274                {
 1275                    if (argument != null)
 276                    {
 0277                        throw new ParseException(
 0278                            $"unexpected argument '{argument}' provided for -o option in proxy string '{s}'");
 279                    }
 1280                    mode = Reference.Mode.ModeOneway;
 1281                    break;
 282                }
 283
 284                case 'O':
 285                {
 1286                    if (argument != null)
 287                    {
 0288                        throw new ParseException(
 0289                            $"unexpected argument '{argument}' provided for -O option in proxy string '{s}'");
 290                    }
 1291                    mode = Reference.Mode.ModeBatchOneway;
 1292                    break;
 293                }
 294
 295                case 'd':
 296                {
 1297                    if (argument != null)
 298                    {
 0299                        throw new ParseException(
 0300                            $"unexpected argument '{argument}' provided for -d option in proxy string '{s}'");
 301                    }
 1302                    mode = Reference.Mode.ModeDatagram;
 1303                    break;
 304                }
 305
 306                case 'D':
 307                {
 1308                    if (argument != null)
 309                    {
 0310                        throw new ParseException(
 0311                            $"unexpected argument '{argument}' provided for -D option in proxy string '{s}'");
 312                    }
 1313                    mode = Reference.Mode.ModeBatchDatagram;
 1314                    break;
 315                }
 316
 317                case 's':
 318                {
 1319                    if (argument != null)
 320                    {
 0321                        throw new ParseException(
 0322                            $"unexpected argument '{argument}' provided for -s option in proxy string '{s}'");
 323                    }
 324                    // Ignored. Only kept for backwards compatibility.
 325                    break;
 326                }
 327
 328                case 'e':
 329                {
 1330                    if (argument == null)
 331                    {
 0332                        throw new ParseException($"no argument provided for -e option in proxy string '{s}'");
 333                    }
 334
 335                    try
 336                    {
 1337                        encoding = Ice.Util.stringToEncodingVersion(argument);
 1338                    }
 0339                    catch (ParseException e)
 340                    {
 0341                        throw new ParseException($"invalid encoding version '{argument}' in proxy string '{s}'", e);
 342                    }
 343                    break;
 344                }
 345
 346                case 'p':
 347                {
 1348                    if (argument == null)
 349                    {
 0350                        throw new ParseException($"no argument provided for -p option in proxy string '{s}'");
 351                    }
 352
 353                    try
 354                    {
 1355                        protocol = Ice.Util.stringToProtocolVersion(argument);
 1356                    }
 0357                    catch (ParseException e)
 358                    {
 0359                        throw new ParseException($"invalid protocol version '{argument}' in proxy string '{s}'", e);
 360                    }
 361                    break;
 362                }
 363
 364                default:
 365                {
 0366                    throw new ParseException($"unknown option '{option}' in proxy string '{s}'");
 367                }
 368            }
 369        }
 370
 1371        if (beg == -1)
 372        {
 1373            return create(ident, facet, mode, protocol, encoding, null, null, propertyPrefix);
 374        }
 375
 1376        var endpoints = new List<EndpointI>();
 377
 1378        if (s[beg] == ':')
 379        {
 1380            var unknownEndpoints = new List<string>();
 1381            end = beg;
 382
 1383            while (end < s.Length && s[end] == ':')
 384            {
 1385                beg = end + 1;
 386
 1387                end = beg;
 1388                while (true)
 389                {
 1390                    end = s.IndexOf(':', end);
 1391                    if (end == -1)
 392                    {
 1393                        end = s.Length;
 1394                        break;
 395                    }
 396                    else
 397                    {
 1398                        bool quoted = false;
 1399                        int quote = beg;
 1400                        while (true)
 401                        {
 1402                            quote = s.IndexOf('\"', quote);
 1403                            if (quote == -1 || end < quote)
 404                            {
 405                                break;
 406                            }
 407                            else
 408                            {
 1409                                quote = s.IndexOf('\"', ++quote);
 1410                                if (quote == -1)
 411                                {
 412                                    break;
 413                                }
 1414                                else if (end < quote)
 415                                {
 1416                                    quoted = true;
 1417                                    break;
 418                                }
 1419                                ++quote;
 420                            }
 421                        }
 1422                        if (!quoted)
 423                        {
 424                            break;
 425                        }
 1426                        ++end;
 427                    }
 428                }
 429
 1430                string es = s[beg..end];
 1431                EndpointI endp = _instance.endpointFactoryManager().create(es, false);
 1432                if (endp != null)
 433                {
 1434                    endpoints.Add(endp);
 435                }
 436                else
 437                {
 1438                    unknownEndpoints.Add(es);
 439                }
 440            }
 1441            if (endpoints.Count == 0)
 442            {
 443                Debug.Assert(unknownEndpoints.Count > 0);
 1444                throw new ParseException($"invalid endpoint '{unknownEndpoints[0]}' in '{s}'");
 445            }
 1446            else if (unknownEndpoints.Count != 0 &&
 1447                    _instance.initializationData().properties.getIcePropertyAsInt("Ice.Warn.Endpoints") > 0)
 448            {
 0449                var msg = new StringBuilder("Proxy contains unknown endpoints:");
 0450                int sz = unknownEndpoints.Count;
 0451                for (int idx = 0; idx < sz; ++idx)
 452                {
 0453                    msg.Append(" `");
 0454                    msg.Append(unknownEndpoints[idx]);
 0455                    msg.Append('\'');
 456                }
 0457                _instance.initializationData().logger.warning(msg.ToString());
 458            }
 459
 1460            EndpointI[] ep = endpoints.ToArray();
 1461            return create(ident, facet, mode, protocol, encoding, ep, null, propertyPrefix);
 462        }
 1463        else if (s[beg] == '@')
 464        {
 1465            beg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, beg + 1);
 1466            if (beg == -1)
 467            {
 0468                throw new ParseException($"missing adapter ID in proxy string '{s}'");
 469            }
 470
 1471            end = Ice.UtilInternal.StringUtil.checkQuote(s, beg);
 472
 473            string adapterstr;
 1474            if (end == -1)
 475            {
 0476                throw new ParseException($"mismatched quotes around adapter ID in proxy string '{s}'");
 477            }
 1478            else if (end == 0)
 479            {
 1480                end = Ice.UtilInternal.StringUtil.findFirstOf(s, delim, beg);
 1481                if (end == -1)
 482                {
 1483                    end = s.Length;
 484                }
 1485                adapterstr = s[beg..end];
 486            }
 487            else
 488            {
 1489                beg++; // Skip leading quote
 1490                adapterstr = s[beg..end];
 1491                end++; // Skip trailing quote
 492            }
 493
 1494            if (end != s.Length && Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
 495            {
 1496                throw new ParseException($"invalid characters after adapter ID in proxy string '{s}'");
 497            }
 498
 499            string adapter;
 500            try
 501            {
 1502                adapter = Ice.UtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.Length, "");
 1503            }
 0504            catch (ArgumentException argEx)
 505            {
 0506                throw new ParseException($"invalid adapter ID in proxy string '{s}'", argEx);
 507            }
 1508            if (adapter.Length == 0)
 509            {
 0510                throw new ParseException($"empty adapter ID in proxy string '{s}'");
 511            }
 1512            return create(ident, facet, mode, protocol, encoding, null, adapter, propertyPrefix);
 513        }
 514
 0515        throw new ParseException($"malformed proxy string '{s}'");
 516    }
 517
 518    internal Reference create(Ice.Identity ident, Ice.InputStream s)
 519    {
 520        //
 521        // Don't read the identity here. Operations calling this
 522        // constructor read the identity, and pass it as a parameter.
 523        //
 524
 1525        if (ident.name.Length == 0 && ident.category.Length == 0)
 526        {
 0527            return null;
 528        }
 529
 530        //
 531        // For compatibility with the old FacetPath.
 532        //
 1533        string[] facetPath = s.readStringSeq();
 534        string facet;
 1535        if (facetPath.Length > 0)
 536        {
 0537            if (facetPath.Length > 1)
 538            {
 0539                throw new MarshalException($"Received invalid facet path with {facetPath.Length} elements.");
 540            }
 0541            facet = facetPath[0];
 542        }
 543        else
 544        {
 1545            facet = "";
 546        }
 547
 1548        int mode = s.readByte();
 1549        if (mode < 0 || mode > (int)Reference.Mode.ModeBatchDatagram)
 550        {
 0551            throw new MarshalException($"Received invalid proxy mode {mode}");
 552        }
 553
 1554        _ = s.readBool(); // the secure field is no longer used
 555
 556        Ice.ProtocolVersion protocol;
 557        Ice.EncodingVersion encoding;
 1558        if (!s.getEncoding().Equals(Ice.Util.Encoding_1_0))
 559        {
 1560            protocol = new Ice.ProtocolVersion(s);
 1561            encoding = new Ice.EncodingVersion(s);
 562        }
 563        else
 564        {
 1565            protocol = Ice.Util.Protocol_1_0;
 1566            encoding = Ice.Util.Encoding_1_0;
 567        }
 568
 1569        EndpointI[] endpoints = null;
 1570        string adapterId = "";
 571
 1572        int sz = s.readSize();
 1573        if (sz > 0)
 574        {
 1575            endpoints = new EndpointI[sz];
 1576            for (int i = 0; i < sz; i++)
 577            {
 1578                endpoints[i] = _instance.endpointFactoryManager().read(s);
 579            }
 580        }
 581        else
 582        {
 1583            adapterId = s.readString();
 584        }
 585
 1586        return create(ident, facet, (Reference.Mode)mode, protocol, encoding, endpoints, adapterId, null);
 587    }
 588
 589    internal ReferenceFactory setDefaultRouter(Ice.RouterPrx defaultRouter)
 590    {
 1591        if (_defaultRouter == null ? defaultRouter == null : _defaultRouter.Equals(defaultRouter))
 592        {
 0593            return this;
 594        }
 595
 1596        var factory = new ReferenceFactory(_instance, _communicator);
 1597        factory._defaultLocator = _defaultLocator;
 1598        factory._defaultRouter = defaultRouter;
 1599        return factory;
 600    }
 601
 1602    internal Ice.RouterPrx getDefaultRouter() => _defaultRouter;
 603
 604    internal ReferenceFactory setDefaultLocator(Ice.LocatorPrx defaultLocator)
 605    {
 1606        if (_defaultLocator == null ? defaultLocator == null : _defaultLocator.Equals(defaultLocator))
 607        {
 0608            return this;
 609        }
 610
 1611        var factory = new ReferenceFactory(_instance, _communicator);
 1612        factory._defaultLocator = defaultLocator;
 1613        factory._defaultRouter = _defaultRouter;
 1614        return factory;
 615    }
 616
 1617    internal Ice.LocatorPrx getDefaultLocator() => _defaultLocator;
 618
 619    //
 620    // Only for use by Instance
 621    //
 1622    internal ReferenceFactory(Instance instance, Ice.Communicator communicator)
 623    {
 1624        _instance = instance;
 1625        _communicator = communicator;
 1626    }
 627
 628    private Reference create(
 629        Ice.Identity ident,
 630        string facet,
 631        Reference.Mode mode,
 632        Ice.ProtocolVersion protocol,
 633        Ice.EncodingVersion encoding,
 634        EndpointI[] endpoints,
 635        string adapterId,
 636        string propertyPrefix)
 637    {
 1638        DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
 639
 640        //
 641        // Default local proxy options.
 642        //
 1643        LocatorInfo locatorInfo = null;
 1644        if (_defaultLocator != null)
 645        {
 1646            if (!((Ice.ObjectPrxHelperBase)_defaultLocator).iceReference().getEncoding().Equals(encoding))
 647            {
 1648                locatorInfo = _instance.locatorManager().get(
 1649                    (Ice.LocatorPrx)_defaultLocator.ice_encodingVersion(encoding));
 650            }
 651            else
 652            {
 1653                locatorInfo = _instance.locatorManager().get(_defaultLocator);
 654            }
 655        }
 1656        RouterInfo routerInfo = _instance.routerManager().get(_defaultRouter);
 1657        bool collocOptimized = defaultsAndOverrides.defaultCollocationOptimization;
 1658        bool cacheConnection = true;
 1659        Ice.EndpointSelectionType endpointSelection = defaultsAndOverrides.defaultEndpointSelection;
 1660        TimeSpan locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout;
 1661        TimeSpan invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout;
 1662        Dictionary<string, string> context = null;
 663
 664        //
 665        // Override the defaults with the proxy properties if a property prefix is defined.
 666        //
 1667        if (propertyPrefix != null && propertyPrefix.Length > 0)
 668        {
 1669            Properties properties = _instance.initializationData().properties;
 670
 1671            Properties.validatePropertiesWithPrefix(propertyPrefix, properties, PropertyNames.ProxyProps);
 672
 673            string property;
 674
 1675            property = propertyPrefix + ".Locator";
 1676            Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property));
 1677            if (locator != null)
 678            {
 1679                if (!((Ice.ObjectPrxHelperBase)locator).iceReference().getEncoding().Equals(encoding))
 680                {
 0681                    locatorInfo = _instance.locatorManager().get(
 0682                        (Ice.LocatorPrx)locator.ice_encodingVersion(encoding));
 683                }
 684                else
 685                {
 1686                    locatorInfo = _instance.locatorManager().get(locator);
 687                }
 688            }
 689
 1690            property = propertyPrefix + ".Router";
 1691            Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(_communicator.propertyToProxy(property));
 1692            if (router != null)
 693            {
 1694                if (propertyPrefix.EndsWith(".Router", StringComparison.Ordinal))
 695                {
 0696                    string s = "`" + property + "=" + properties.getProperty(property) +
 0697                        "': cannot set a router on a router; setting ignored";
 0698                    _instance.initializationData().logger.warning(s);
 699                }
 700                else
 701                {
 1702                    routerInfo = _instance.routerManager().get(router);
 703                }
 704            }
 705
 1706            property = propertyPrefix + ".CollocationOptimized";
 1707            collocOptimized = properties.getPropertyAsIntWithDefault(property, collocOptimized ? 1 : 0) > 0;
 708
 1709            property = propertyPrefix + ".ConnectionCached";
 1710            cacheConnection = properties.getPropertyAsIntWithDefault(property, cacheConnection ? 1 : 0) > 0;
 711
 1712            property = propertyPrefix + ".EndpointSelection";
 1713            if (properties.getProperty(property).Length > 0)
 714            {
 1715                string type = properties.getProperty(property);
 1716                if (type == "Random")
 717                {
 1718                    endpointSelection = Ice.EndpointSelectionType.Random;
 719                }
 1720                else if (type == "Ordered")
 721                {
 1722                    endpointSelection = Ice.EndpointSelectionType.Ordered;
 723                }
 724                else
 725                {
 0726                    throw new ParseException(
 0727                        $"illegal value '{type}' in property '{property}'; expected 'Random' or 'Ordered'");
 728                }
 729            }
 730
 1731            property = propertyPrefix + ".LocatorCacheTimeout";
 1732            locatorCacheTimeout = TimeSpan.FromSeconds(
 1733                properties.getPropertyAsIntWithDefault(property, (int)locatorCacheTimeout.TotalSeconds));
 734
 1735            property = propertyPrefix + ".InvocationTimeout";
 1736            invocationTimeout = TimeSpan.FromMilliseconds(
 1737                properties.getPropertyAsIntWithDefault(property, (int)invocationTimeout.TotalMilliseconds));
 738
 1739            property = propertyPrefix + ".Context.";
 1740            Dictionary<string, string> contexts = properties.getPropertiesForPrefix(property);
 1741            if (contexts.Count != 0)
 742            {
 1743                context = new Dictionary<string, string>();
 1744                foreach (KeyValuePair<string, string> e in contexts)
 745                {
 1746                    context.Add(e.Key[property.Length..], e.Value);
 747                }
 748            }
 749        }
 750
 751        //
 752        // Create new reference
 753        //
 1754        return new RoutableReference(
 1755            _instance,
 1756            _communicator,
 1757            ident,
 1758            facet,
 1759            mode,
 1760            compress: null,
 1761            protocol,
 1762            encoding,
 1763            endpoints,
 1764            adapterId,
 1765            locatorInfo,
 1766            routerInfo,
 1767            collocOptimized,
 1768            cacheConnection,
 1769            endpointSelection,
 1770            locatorCacheTimeout,
 1771            invocationTimeout,
 1772            context);
 773    }
 774
 775    private readonly Instance _instance;
 776    private readonly Ice.Communicator _communicator;
 777    private Ice.RouterPrx _defaultRouter;
 778    private Ice.LocatorPrx _defaultLocator;
 779}