Пример #1
0
        public DefIDFull GetID(IDef res)
        {
            lock (this)
            {
                if (res == null)
                {
                    return(default(DefIDFull));
                }

                try
                {
                    return(_objectsToPaths[res]);
                }
                catch (KeyNotFoundException)
                {
                    throw new KeyNotFoundException($"Key {res} was not found in the dictionary");
                }
            }
        }
Пример #2
0
        public bool GetExisting(DefIDFull id, Type type, out IDef res)
        {
            lock (this)
            {
                if (!_pathsToObjects.TryGetValue(id, out res))
                {
                    return(false);
                }

                if (res == null)
                {
                    return(true);
                }

                if (!type.IsInstanceOfType(res))
                {
                    res = null;
                }

                return(true);
            }
        }