/// <inheritdoc /> public bool TryResolve(FormKey formKey, Type type, [MaybeNullWhen(false)] out IMajorRecordCommonGetter majorRec) { if (!_hasAny || formKey.IsNull) { majorRec = default; return(false); } DepthCache <IMajorRecordCommonGetter> cache; lock (this._winningRecords) { // Get cache object by type if (!this._winningRecords.TryGetValue(type, out cache)) { cache = new DepthCache <IMajorRecordCommonGetter>(); if (type.Equals(typeof(IMajorRecordCommon)) || type.Equals(typeof(IMajorRecordCommonGetter))) { this._winningRecords[typeof(IMajorRecordCommon)] = cache; this._winningRecords[typeof(IMajorRecordCommonGetter)] = cache; } else if (LoquiRegistration.TryGetRegister(type, out var registration)) { this._winningRecords[registration.ClassType] = cache; this._winningRecords[registration.GetterType] = cache; this._winningRecords[registration.SetterType] = cache; if (registration.InternalGetterType != null) { this._winningRecords[registration.InternalGetterType] = cache; } if (registration.InternalSetterType != null) { this._winningRecords[registration.InternalSetterType] = cache; } } else { if (!_linkInterfaces.TryGetValue(type, out var objs)) { throw new ArgumentException($"A lookup was queried for an unregistered type: {type.Name}"); } this._winningRecords[type] = cache; } } } lock (cache) { // Check for record if (cache.TryGetValue(formKey, out majorRec)) { return(true); } if (IsPastDepth(cache.Depth)) { majorRec = default !;
private bool ShouldStopQuery <T>(FormKey targetKey, DepthCache <T> cache) { if (cache.Depth >= this._listedOrder.Count) { return(true); } // If we're going deeper than the originating mod of the target FormKey, we can stop if (cache.PassedMods.Contains(targetKey.ModKey)) { return(true); } return(false); }