< Summary

Information
Class: Ice.Internal.ReferenceFactory
Assembly: Ice
File(s): /_/csharp/src/Ice/Internal/ReferenceFactory.cs
Tag: 106_26348240760
Line coverage
83%
Covered lines: 280
Uncovered lines: 56
Coverable lines: 336
Total lines: 780
Line coverage: 83.3%
Branch coverage
74%
Covered branches: 147
Total branches: 197
Branch coverage: 74.6%
Method coverage
100%
Covered methods: 12
Fully covered methods: 3
Total methods: 12
Method coverage: 100%
Full method coverage: 25%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
create(...)25%4490.91%
create(...)25%4490.91%
create(...)50%6692.86%
copy(...)25%4475%
create(...)80.31%28912778.41%
create(...)55.56%201880.77%
setDefaultRouter(...)75%4483.33%
getDefaultRouter()100%11100%
setDefaultLocator(...)75%4483.33%
getDefaultLocator()100%11100%
.ctor(...)100%11100%
create(...)88.46%272690.79%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Diagnostics;
 4using System.Text;
 5
 6namespace Ice.Internal;
 7
 8internal class ReferenceFactory
 9{
 10    internal Reference
 11    create(Ice.Identity ident, string facet, Reference tmpl, EndpointI[] endpoints)
 12    {
 113        if (ident.name.Length == 0 && ident.category.Length == 0)
 14        {
 015            return null;
 16        }
 17
 118        return create(
 119            ident,
 120            facet,
 121            tmpl.getMode(),
 122            tmpl.getProtocol(),
 123            tmpl.getEncoding(),
 124            endpoints,
 125            null,
 126            null);
 27    }
 28
 29    internal Reference
 30    create(Ice.Identity ident, string facet, Reference tmpl, string adapterId)
 31    {
 132        if (ident.name.Length == 0 && ident.category.Length == 0)
 33        {
 034            return null;
 35        }
 36
 37        //
 38        // Create new reference
 39        //
 140        return create(
 141            ident,
 142            facet,
 143            tmpl.getMode(),
 144            tmpl.getProtocol(),
 145            tmpl.getEncoding(),
 146            null,
 147            adapterId,
 148            null);
 49    }
 50
 51    internal Reference create(Ice.Identity ident, Ice.ConnectionI connection)
 52    {
 153        if (ident.name.Length == 0 && ident.category.Length == 0)
 54        {
 055            return null;
 56        }
 57
 58        //
 59        // Create new reference
 60        //
 161        return new FixedReference(
 162            _instance,
 163            _communicator,
 164            ident,
 165            "", // Facet
 166            connection.endpoint().datagram() ? Reference.Mode.ModeDatagram : Reference.Mode.ModeTwoway,
 167            compress: null,
 168            Protocol.Protocol_1_0,
 169            _instance.defaultsAndOverrides().defaultEncoding,
 170            connection,
 171            TimeSpan.FromMilliseconds(-1),
 172            null);
 73    }
 74
 75    internal Reference copy(Reference r)
 76    {
 177        Ice.Identity ident = r.getIdentity();
 178        if (ident.name.Length == 0 && ident.category.Length == 0)
 79        {
 080            return null;
 81        }
 182        return r.Clone();
 83    }
 84
 85    internal Reference create(string s, string propertyPrefix)
 86    {
 187        if (s.Length == 0)
 88        {
 189            return null;
 90        }
 91
 92        const string delim = " \t\n\r";
 93
 94        int beg;
 195        int end = 0;
 96
 197        beg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end);
 198        if (beg == -1)
 99        {
 0100            throw new ParseException($"no non-whitespace characters found in proxy string '{s}'");
 101        }
 102
 1103        end = Ice.UtilInternal.StringUtil.checkQuote(s, beg);
 104
 105        //
 106        // Extract the identity, which may be enclosed in single
 107        // or double quotation marks.
 108        //
 109        string idstr;
 1110        if (end == -1)
 111        {
 1112            throw new ParseException($"mismatched quotes around identity in proxy string '{s}'");
 113        }
 1114        else if (end == 0)
 115        {
 1116            end = Ice.UtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg);
 1117            if (end == -1)
 118            {
 1119                end = s.Length;
 120            }
 1121            idstr = s[beg..end];
 122        }
 123        else
 124        {
 1125            beg++; // Skip leading quote
 1126            idstr = s[beg..end];
 1127            end++; // Skip trailing quote
 128        }
 129
 1130        if (beg == end)
 131        {
 0132            throw new ParseException($"no identity in proxy string '{s}'");
 133        }
 134
 135        //
 136        // Parsing the identity may raise ParseException.
 137        //
 1138        Ice.Identity ident = Ice.Util.stringToIdentity(idstr);
 139
 1140        if (ident.name.Length == 0)
 141        {
 142            //
 143            // An identity with an empty name and a non-empty
 144            // category is illegal.
 145            //
 1146            if (ident.category.Length > 0)
 147            {
 0148                throw new ParseException("The category of a null Ice object identity must be empty.");
 149            }
 150            //
 151            // Treat a stringified proxy containing two double
 152            // quotes ("") the same as an empty string, i.e.,
 153            // a null proxy, but only if nothing follows the
 154            // quotes.
 155            //
 1156            else if (Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
 157            {
 1158                throw new ParseException($"invalid characters after identity in proxy string '{s}'");
 159            }
 160            else
 161            {
 1162                return null;
 163            }
 164        }
 165
 1166        string facet = "";
 1167        Reference.Mode mode = Reference.Mode.ModeTwoway;
 1168        Ice.EncodingVersion encoding = _instance.defaultsAndOverrides().defaultEncoding;
 1169        Ice.ProtocolVersion protocol = Protocol.Protocol_1_0;
 170        while (true)
 171        {
 1172            beg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end);
 1173            if (beg == -1)
 174            {
 175                break;
 176            }
 177
 1178            if (s[beg] == ':' || s[beg] == '@')
 179            {
 180                break;
 181            }
 182
 1183            end = Ice.UtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg);
 1184            if (end == -1)
 185            {
 1186                end = s.Length;
 187            }
 188
 1189            if (beg == end)
 190            {
 191                break;
 192            }
 193
 1194            string option = s[beg..end];
 1195            if (option.Length != 2 || option[0] != '-')
 196            {
 1197                throw new ParseException($"expected a proxy option but found '{option}' in proxy string '{s}'");
 198            }
 199
 200            //
 201            // Check for the presence of an option argument. The
 202            // argument may be enclosed in single or double
 203            // quotation marks.
 204            //
 1205            string argument = null;
 1206            int argumentBeg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end);
 1207            if (argumentBeg != -1)
 208            {
 1209                char ch = s[argumentBeg];
 1210                if (ch != '@' && ch != ':' && ch != '-')
 211                {
 1212                    beg = argumentBeg;
 1213                    end = Ice.UtilInternal.StringUtil.checkQuote(s, beg);
 1214                    if (end == -1)
 215                    {
 1216                        throw new ParseException(
 1217                            $"mismatched quotes around value for {option} option in proxy string '{s}'");
 218                    }
 1219                    else if (end == 0)
 220                    {
 1221                        end = Ice.UtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg);
 1222                        if (end == -1)
 223                        {
 1224                            end = s.Length;
 225                        }
 1226                        argument = s[beg..end];
 227                    }
 228                    else
 229                    {
 1230                        beg++; // Skip leading quote
 1231                        argument = s[beg..end];
 1232                        end++; // Skip trailing quote
 233                    }
 234                }
 235            }
 236
 237            //
 238            // If any new options are added here,
 239            // Ice.Internal::Reference::toString() and its derived classes must be updated as well.
 240            //
 1241            switch (option[1])
 242            {
 243                case 'f':
 244                {
 1245                    if (argument == null)
 246                    {
 0247                        throw new ParseException($"no argument provided for -f option in proxy string '{s}'");
 248                    }
 249
 250                    try
 251                    {
 1252                        facet = Ice.UtilInternal.StringUtil.unescapeString(argument, 0, argument.Length, "");
 1253                    }
 0254                    catch (ArgumentException argEx)
 255                    {
 0256                        throw new ParseException($"invalid facet in proxy string '{s}'", argEx);
 257                    }
 258                    break;
 259                }
 260
 261                case 't':
 262                {
 1263                    if (argument != null)
 264                    {
 0265                        throw new ParseException(
 0266                            $"unexpected argument '{argument}' provided for -t option in proxy string '{s}'");
 267                    }
 1268                    mode = Reference.Mode.ModeTwoway;
 1269                    break;
 270                }
 271
 272                case 'o':
 273                {
 1274                    if (argument != null)
 275                    {
 0276                        throw new ParseException(
 0277                            $"unexpected argument '{argument}' provided for -o option in proxy string '{s}'");
 278                    }
 1279                    mode = Reference.Mode.ModeOneway;
 1280                    break;
 281                }
 282
 283                case 'O':
 284                {
 1285                    if (argument != null)
 286                    {
 0287                        throw new ParseException(
 0288                            $"unexpected argument '{argument}' provided for -O option in proxy string '{s}'");
 289                    }
 1290                    mode = Reference.Mode.ModeBatchOneway;
 1291                    break;
 292                }
 293
 294                case 'd':
 295                {
 1296                    if (argument != null)
 297                    {
 0298                        throw new ParseException(
 0299                            $"unexpected argument '{argument}' provided for -d option in proxy string '{s}'");
 300                    }
 1301                    mode = Reference.Mode.ModeDatagram;
 1302                    break;
 303                }
 304
 305                case 'D':
 306                {
 1307                    if (argument != null)
 308                    {
 0309                        throw new ParseException(
 0310                            $"unexpected argument '{argument}' provided for -D option in proxy string '{s}'");
 311                    }
 1312                    mode = Reference.Mode.ModeBatchDatagram;
 1313                    break;
 314                }
 315
 316                case 's':
 317                {
 1318                    if (argument != null)
 319                    {
 0320                        throw new ParseException(
 0321                            $"unexpected argument '{argument}' provided for -s option in proxy string '{s}'");
 322                    }
 323                    // Ignored. Only kept for backwards compatibility.
 324                    break;
 325                }
 326
 327                case 'e':
 328                {
 1329                    if (argument == null)
 330                    {
 0331                        throw new ParseException($"no argument provided for -e option in proxy string '{s}'");
 332                    }
 333
 334                    try
 335                    {
 1336                        encoding = Protocol.stringToEncodingVersion(argument);
 1337                    }
 0338                    catch (ParseException e)
 339                    {
 0340                        throw new ParseException($"invalid encoding version '{argument}' in proxy string '{s}'", e);
 341                    }
 342                    break;
 343                }
 344
 345                case 'p':
 346                {
 1347                    if (argument == null)
 348                    {
 0349                        throw new ParseException($"no argument provided for -p option in proxy string '{s}'");
 350                    }
 351
 352                    try
 353                    {
 1354                        protocol = Protocol.stringToProtocolVersion(argument);
 1355                    }
 0356                    catch (ParseException e)
 357                    {
 0358                        throw new ParseException($"invalid protocol version '{argument}' in proxy string '{s}'", e);
 359                    }
 360                    break;
 361                }
 362
 363                default:
 364                {
 0365                    throw new ParseException($"unknown option '{option}' in proxy string '{s}'");
 366                }
 367            }
 368        }
 369
 1370        if (beg == -1)
 371        {
 1372            return create(ident, facet, mode, protocol, encoding, null, null, propertyPrefix);
 373        }
 374
 1375        var endpoints = new List<EndpointI>();
 376
 1377        if (s[beg] == ':')
 378        {
 1379            var unknownEndpoints = new List<string>();
 1380            end = beg;
 381
 1382            while (end < s.Length && s[end] == ':')
 383            {
 1384                beg = end + 1;
 385
 1386                end = beg;
 1387                while (true)
 388                {
 1389                    end = s.IndexOf(':', end);
 1390                    if (end == -1)
 391                    {
 1392                        end = s.Length;
 1393                        break;
 394                    }
 395                    else
 396                    {
 1397                        bool quoted = false;
 1398                        int quote = beg;
 1399                        while (true)
 400                        {
 1401                            quote = s.IndexOf('\"', quote);
 1402                            if (quote == -1 || end < quote)
 403                            {
 404                                break;
 405                            }
 406                            else
 407                            {
 1408                                quote = s.IndexOf('\"', ++quote);
 1409                                if (quote == -1)
 410                                {
 411                                    break;
 412                                }
 1413                                else if (end < quote)
 414                                {
 1415                                    quoted = true;
 1416                                    break;
 417                                }
 1418                                ++quote;
 419                            }
 420                        }
 1421                        if (!quoted)
 422                        {
 423                            break;
 424                        }
 1425                        ++end;
 426                    }
 427                }
 428
 1429                string es = s[beg..end];
 1430                EndpointI endp = _instance.endpointFactoryManager().create(es, false);
 1431                if (endp != null)
 432                {
 1433                    endpoints.Add(endp);
 434                }
 435                else
 436                {
 1437                    unknownEndpoints.Add(es);
 438                }
 439            }
 1440            if (endpoints.Count == 0)
 441            {
 442                Debug.Assert(unknownEndpoints.Count > 0);
 1443                throw new ParseException($"invalid endpoint '{unknownEndpoints[0]}' in '{s}'");
 444            }
 1445            else if (unknownEndpoints.Count != 0 &&
 1446                    _instance.initializationData().properties.getIcePropertyAsInt("Ice.Warn.Endpoints") > 0)
 447            {
 0448                var msg = new StringBuilder("Proxy contains unknown endpoints:");
 0449                int sz = unknownEndpoints.Count;
 0450                for (int idx = 0; idx < sz; ++idx)
 451                {
 0452                    msg.Append(" `");
 0453                    msg.Append(unknownEndpoints[idx]);
 0454                    msg.Append('\'');
 455                }
 0456                _instance.initializationData().logger.warning(msg.ToString());
 457            }
 458
 1459            EndpointI[] ep = endpoints.ToArray();
 1460            return create(ident, facet, mode, protocol, encoding, ep, null, propertyPrefix);
 461        }
 1462        else if (s[beg] == '@')
 463        {
 1464            beg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, beg + 1);
 1465            if (beg == -1)
 466            {
 0467                throw new ParseException($"missing adapter ID in proxy string '{s}'");
 468            }
 469
 1470            end = Ice.UtilInternal.StringUtil.checkQuote(s, beg);
 471
 472            string adapterstr;
 1473            if (end == -1)
 474            {
 0475                throw new ParseException($"mismatched quotes around adapter ID in proxy string '{s}'");
 476            }
 1477            else if (end == 0)
 478            {
 1479                end = Ice.UtilInternal.StringUtil.findFirstOf(s, delim, beg);
 1480                if (end == -1)
 481                {
 1482                    end = s.Length;
 483                }
 1484                adapterstr = s[beg..end];
 485            }
 486            else
 487            {
 1488                beg++; // Skip leading quote
 1489                adapterstr = s[beg..end];
 1490                end++; // Skip trailing quote
 491            }
 492
 1493            if (end != s.Length && Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
 494            {
 1495                throw new ParseException($"invalid characters after adapter ID in proxy string '{s}'");
 496            }
 497
 498            string adapter;
 499            try
 500            {
 1501                adapter = Ice.UtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.Length, "");
 1502            }
 0503            catch (ArgumentException argEx)
 504            {
 0505                throw new ParseException($"invalid adapter ID in proxy string '{s}'", argEx);
 506            }
 1507            if (adapter.Length == 0)
 508            {
 0509                throw new ParseException($"empty adapter ID in proxy string '{s}'");
 510            }
 1511            return create(ident, facet, mode, protocol, encoding, null, adapter, propertyPrefix);
 512        }
 513
 0514        throw new ParseException($"malformed proxy string '{s}'");
 515    }
 516
 517    internal Reference create(Ice.Identity ident, Ice.InputStream s)
 518    {
 519        //
 520        // Don't read the identity here. Operations calling this
 521        // constructor read the identity, and pass it as a parameter.
 522        //
 523
 1524        if (ident.name.Length == 0 && ident.category.Length == 0)
 525        {
 0526            return null;
 527        }
 528
 529        //
 530        // For compatibility with the old FacetPath.
 531        //
 1532        string[] facetPath = s.readStringSeq();
 533        string facet;
 1534        if (facetPath.Length > 0)
 535        {
 0536            if (facetPath.Length > 1)
 537            {
 0538                throw new MarshalException($"Received invalid facet path with {facetPath.Length} elements.");
 539            }
 0540            facet = facetPath[0];
 541        }
 542        else
 543        {
 1544            facet = "";
 545        }
 546
 1547        int mode = s.readByte();
 1548        if (mode < 0 || mode > (int)Reference.Mode.ModeBatchDatagram)
 549        {
 0550            throw new MarshalException($"Received invalid proxy mode {mode}");
 551        }
 552
 1553        _ = s.readBool(); // the secure field is no longer used
 554
 555        Ice.ProtocolVersion protocol;
 556        Ice.EncodingVersion encoding;
 1557        if (!s.getEncoding().Equals(Ice.Util.Encoding_1_0))
 558        {
 1559            protocol = new Ice.ProtocolVersion(s);
 1560            encoding = new Ice.EncodingVersion(s);
 561        }
 562        else
 563        {
 1564            protocol = Protocol.Protocol_1_0;
 1565            encoding = Ice.Util.Encoding_1_0;
 566        }
 567
 1568        EndpointI[] endpoints = null;
 1569        string adapterId = "";
 570
 571        // Each endpoint occupies at least 8 bytes on the wire (a 2-byte type plus a 6-byte minimum
 572        // encapsulation), so readAndCheckSeqSize rejects an oversized count before we allocate.
 1573        int sz = s.readAndCheckSeqSize(8);
 1574        if (sz > 0)
 575        {
 1576            endpoints = new EndpointI[sz];
 1577            for (int i = 0; i < sz; i++)
 578            {
 1579                endpoints[i] = _instance.endpointFactoryManager().read(s);
 580            }
 581        }
 582        else
 583        {
 1584            adapterId = s.readString();
 585        }
 586
 1587        return create(ident, facet, (Reference.Mode)mode, protocol, encoding, endpoints, adapterId, null);
 588    }
 589
 590    internal ReferenceFactory setDefaultRouter(Ice.RouterPrx defaultRouter)
 591    {
 1592        if (_defaultRouter == null ? defaultRouter == null : _defaultRouter.Equals(defaultRouter))
 593        {
 0594            return this;
 595        }
 596
 1597        var factory = new ReferenceFactory(_instance, _communicator);
 1598        factory._defaultLocator = _defaultLocator;
 1599        factory._defaultRouter = defaultRouter;
 1600        return factory;
 601    }
 602
 1603    internal Ice.RouterPrx getDefaultRouter() => _defaultRouter;
 604
 605    internal ReferenceFactory setDefaultLocator(Ice.LocatorPrx defaultLocator)
 606    {
 1607        if (_defaultLocator == null ? defaultLocator == null : _defaultLocator.Equals(defaultLocator))
 608        {
 0609            return this;
 610        }
 611
 1612        var factory = new ReferenceFactory(_instance, _communicator);
 1613        factory._defaultLocator = defaultLocator;
 1614        factory._defaultRouter = _defaultRouter;
 1615        return factory;
 616    }
 617
 1618    internal Ice.LocatorPrx getDefaultLocator() => _defaultLocator;
 619
 620    //
 621    // Only for use by Instance
 622    //
 1623    internal ReferenceFactory(Instance instance, Ice.Communicator communicator)
 624    {
 1625        _instance = instance;
 1626        _communicator = communicator;
 1627    }
 628
 629    private Reference create(
 630        Ice.Identity ident,
 631        string facet,
 632        Reference.Mode mode,
 633        Ice.ProtocolVersion protocol,
 634        Ice.EncodingVersion encoding,
 635        EndpointI[] endpoints,
 636        string adapterId,
 637        string propertyPrefix)
 638    {
 1639        DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
 640
 641        //
 642        // Default local proxy options.
 643        //
 1644        LocatorInfo locatorInfo = null;
 1645        if (_defaultLocator != null)
 646        {
 1647            if (!((Ice.ObjectPrxHelperBase)_defaultLocator).iceReference().getEncoding().Equals(encoding))
 648            {
 1649                locatorInfo = _instance.locatorManager().get(
 1650                    (Ice.LocatorPrx)_defaultLocator.ice_encodingVersion(encoding));
 651            }
 652            else
 653            {
 1654                locatorInfo = _instance.locatorManager().get(_defaultLocator);
 655            }
 656        }
 1657        RouterInfo routerInfo = _instance.routerManager().get(_defaultRouter);
 1658        bool collocOptimized = defaultsAndOverrides.defaultCollocationOptimization;
 1659        bool cacheConnection = true;
 1660        Ice.EndpointSelectionType endpointSelection = defaultsAndOverrides.defaultEndpointSelection;
 1661        TimeSpan locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout;
 1662        TimeSpan invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout;
 1663        Dictionary<string, string> context = null;
 664
 665        //
 666        // Override the defaults with the proxy properties if a property prefix is defined.
 667        //
 1668        if (propertyPrefix != null && propertyPrefix.Length > 0)
 669        {
 1670            Properties properties = _instance.initializationData().properties;
 671
 1672            Properties.validatePropertiesWithPrefix(propertyPrefix, properties, PropertyNames.ProxyProps);
 673
 674            string property;
 675
 1676            property = propertyPrefix + ".Locator";
 1677            Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property));
 1678            if (locator != null)
 679            {
 1680                if (!((Ice.ObjectPrxHelperBase)locator).iceReference().getEncoding().Equals(encoding))
 681                {
 0682                    locatorInfo = _instance.locatorManager().get(
 0683                        (Ice.LocatorPrx)locator.ice_encodingVersion(encoding));
 684                }
 685                else
 686                {
 1687                    locatorInfo = _instance.locatorManager().get(locator);
 688                }
 689            }
 690
 1691            property = propertyPrefix + ".Router";
 1692            Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(_communicator.propertyToProxy(property));
 1693            if (router != null)
 694            {
 1695                if (propertyPrefix.EndsWith(".Router", StringComparison.Ordinal))
 696                {
 0697                    string s = "`" + property + "=" + properties.getProperty(property) +
 0698                        "': cannot set a router on a router; setting ignored";
 0699                    _instance.initializationData().logger.warning(s);
 700                }
 701                else
 702                {
 1703                    routerInfo = _instance.routerManager().get(router);
 704                }
 705            }
 706
 1707            property = propertyPrefix + ".CollocationOptimized";
 1708            collocOptimized = properties.getPropertyAsIntWithDefault(property, collocOptimized ? 1 : 0) > 0;
 709
 1710            property = propertyPrefix + ".ConnectionCached";
 1711            cacheConnection = properties.getPropertyAsIntWithDefault(property, cacheConnection ? 1 : 0) > 0;
 712
 1713            property = propertyPrefix + ".EndpointSelection";
 1714            if (properties.getProperty(property).Length > 0)
 715            {
 1716                string type = properties.getProperty(property);
 1717                if (type == "Random")
 718                {
 1719                    endpointSelection = Ice.EndpointSelectionType.Random;
 720                }
 1721                else if (type == "Ordered")
 722                {
 1723                    endpointSelection = Ice.EndpointSelectionType.Ordered;
 724                }
 725                else
 726                {
 0727                    throw new ParseException(
 0728                        $"illegal value '{type}' in property '{property}'; expected 'Random' or 'Ordered'");
 729                }
 730            }
 731
 1732            property = propertyPrefix + ".LocatorCacheTimeout";
 1733            locatorCacheTimeout = TimeSpan.FromSeconds(
 1734                properties.getPropertyAsIntWithDefault(property, (int)locatorCacheTimeout.TotalSeconds));
 735
 1736            property = propertyPrefix + ".InvocationTimeout";
 1737            invocationTimeout = TimeSpan.FromMilliseconds(
 1738                properties.getPropertyAsIntWithDefault(property, (int)invocationTimeout.TotalMilliseconds));
 739
 1740            property = propertyPrefix + ".Context.";
 1741            Dictionary<string, string> contexts = properties.getPropertiesForPrefix(property);
 1742            if (contexts.Count != 0)
 743            {
 1744                context = new Dictionary<string, string>();
 1745                foreach (KeyValuePair<string, string> e in contexts)
 746                {
 1747                    context.Add(e.Key[property.Length..], e.Value);
 748                }
 749            }
 750        }
 751
 752        //
 753        // Create new reference
 754        //
 1755        return new RoutableReference(
 1756            _instance,
 1757            _communicator,
 1758            ident,
 1759            facet,
 1760            mode,
 1761            compress: null,
 1762            protocol,
 1763            encoding,
 1764            endpoints,
 1765            adapterId,
 1766            locatorInfo,
 1767            routerInfo,
 1768            collocOptimized,
 1769            cacheConnection,
 1770            endpointSelection,
 1771            locatorCacheTimeout,
 1772            invocationTimeout,
 1773            context);
 774    }
 775
 776    private readonly Instance _instance;
 777    private readonly Ice.Communicator _communicator;
 778    private Ice.RouterPrx _defaultRouter;
 779    private Ice.LocatorPrx _defaultLocator;
 780}