// Returns locator info for a given locator. Automatically creates
        // the locator info if it doesn't exist yet.
        internal LocatorInfo GetLocatorInfo(ILocatorPrx loc)
        {
            // The locator can't be located.
            ILocatorPrx locator = loc.Clone(clearLocator: true);

            // TODO: reap unused locator info objects?
            lock (_locatorInfoMap)
            {
                if (!_locatorInfoMap.TryGetValue(locator, out LocatorInfo? info))
                {
                    // Rely on locator identity for the adapter table. We want to
                    // have only one table per locator (not one per locator
                    // proxy).
                    var key = new LocatorKey(locator);
                    if (!_locatorTableMap.TryGetValue(key, out LocatorTable? table))
                    {
                        table = new LocatorTable();
                        _locatorTableMap[key] = table;
                    }

                    info = new LocatorInfo(locator, table, _backgroundLocatorCacheUpdates);
                    _locatorInfoMap[locator] = info;
                }

                return(info);
            }
        }
示例#2
0
文件: AllTests.cs 项目: cyyever/ice
        private static IObjectPrx?ResolveLocation(ILocatorPrx locator, string adapterId)
        {
            if (locator.Protocol == Protocol.Ice1)
            {
                return(locator.FindAdapterById(adapterId));
            }
            else
            {
                EndpointData[] dataArray = locator.ResolveLocation(ImmutableArray.Create(adapterId));

                return(dataArray.Length > 0 ?
                       locator.Clone(endpoints: dataArray.ToEndpointList(locator.Communicator)) : null);
            }
        }
示例#3
0
        //
        // Returns locator info for a given locator. Automatically creates
        // the locator info if it doesn't exist yet.
        //
        public LocatorInfo get(ILocatorPrx loc)
        {
            if (loc == null)
            {
                throw new System.ArgumentNullException(nameof(loc));
            }

            //
            // The locator can't be located.
            //
            ILocatorPrx locator = loc.Clone(clearLocator: true);

            //
            // TODO: reap unused locator info objects?
            //
            lock (this)
            {
                LocatorInfo info;
                if (!_table.TryGetValue(locator, out info))
                {
                    //
                    // Rely on locator identity for the adapter table. We want to
                    // have only one table per locator (not one per locator
                    // proxy).
                    //
                    LocatorTable?table = null;
                    LocatorKey   key   = new LocatorKey(locator);
                    if (!_locatorTables.TryGetValue(key, out table))
                    {
                        table = new LocatorTable();
                        _locatorTables[key] = table;
                    }

                    info            = new LocatorInfo(locator, table, _background);
                    _table[locator] = info;
                }

                return(info);
            }
        }