/// <summary> /// Locates link winning target record in given Link Cache. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Located Major Record, or null if not located</returns> /// <typeparam name="TMajor">Major Record type of the FormLink</typeparam> public static TMajor?TryResolve <TMajor>(this IFormLinkGetter link, ILinkCache cache) where TMajor : class, IMajorRecordCommonGetter { if (link.TryResolve <TMajor>(cache, out var majorRecord)) { return(majorRecord); } return(null); }
public void Write <T>( MutagenWriter writer, IFormLinkGetter <T> item) where T : class, IMajorRecordGetter { FormKeyBinaryTranslation.Instance.Write( writer, item.FormKey); }
/// <summary> /// Locates link winning target record in given Link Cache. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Located Major Record, or null if not located</returns> /// <typeparam name="TMajor">Major Record type of the FormLink</typeparam> /// <typeparam name="TScopedMajor">Major Record type to resolve to</typeparam> public static TScopedMajor?TryResolve <TMajor, TScopedMajor>(this IFormLinkGetter <TMajor> link, ILinkCache cache) where TMajor : class, IMajorRecordGetter where TScopedMajor : class, TMajor { if (link.TryResolve <TMajor, TScopedMajor>(cache, out var majorRecord)) { return(majorRecord); } return(null); }
/// <summary> /// Attempts to locate link winning target record in given Link Cache. /// </summary> /// <param name="link">FormLink to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <param name="majorRecord">Located record if successful</param> /// <returns>True if link was resolved and a record was retrieved</returns> /// <typeparam name="TMajor">Major Record type to resolve to</typeparam> public static bool TryResolve <TMajor>(this IFormLinkGetter link, ILinkCache cache, [MaybeNullWhen(false)] out TMajor majorRecord) where TMajor : class, IMajorRecordCommonGetter { if (!link.FormKeyNullable.TryGet(out var formKey)) { majorRecord = default; return(false); } return(cache.TryResolve(formKey, out majorRecord)); }
/// <summary> /// Locate all of a link's target records in given Link Cache.<br /> /// The winning override will be returned first, and finished by the original defining definition. /// </summary> /// <param name="link">FormLink to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Enumerable of the linked records</returns> /// <typeparam name="TSource">Major Record type that the FormLink specifies explicitly</typeparam> /// <typeparam name="TScopedMajor">Inheriting Major Record type to scope to</typeparam> public static IEnumerable <TScopedMajor> ResolveAll <TSource, TScopedMajor>(this IFormLinkGetter <TSource> link, ILinkCache cache) where TSource : class, IMajorRecordCommonGetter where TScopedMajor : class, TSource { if (!link.FormKeyNullable.TryGet(out var formKey)) { return(Enumerable.Empty <TScopedMajor>()); } return(cache.ResolveAll <TScopedMajor>(formKey)); }
/// <summary> /// Locate all of a link's target records in given Link Cache.<br /> /// The winning override will be returned first, and finished by the original defining definition. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Enumerable of the linked records</returns> /// <typeparam name="TMajor">Major Record type to resolve to</typeparam> public static IEnumerable <TMajor> ResolveAll <TMajor>(this IFormLinkGetter <TMajor> link, ILinkCache cache) where TMajor : class, IMajorRecordGetter { if (link.FormKeyNullable is not { } formKey) { return(Enumerable.Empty <TMajor>()); } return(cache.ResolveAll <TMajor>(formKey)); }
private static IFormLinkGetter <TMajorGetter> RelinkToNew <TMajorGetter>(this IFormLinkGetter <TMajorGetter> link, IReadOnlyDictionary <FormKey, FormKey> mapping) where TMajorGetter : class, IMajorRecordCommonGetter { if (!link.IsNull && mapping.TryGetValue(link.FormKey, out var replacement)) { return(new FormLink <TMajorGetter>(replacement)); } return(link); }
/// <summary> /// Locates link winning target record in given Link Cache. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Located Major Record</returns> /// <exception cref="NullReferenceException">If link was not successful</exception> /// <typeparam name="TMajor">Major Record type to resolve to</typeparam> public static IModContext <TMajor>?ResolveSimpleContext <TMajor>( this IFormLinkGetter <TMajor> link, ILinkCache cache) where TMajor : class, IMajorRecordGetter { if (link.TryResolveSimpleContext <TMajor>(cache, out var majorRecord)) { return(majorRecord); } return(null); }
public void Write <T>( MutagenWriter writer, IFormLinkGetter <T> item, RecordType header) where T : class, IMajorRecordCommonGetter { FormKeyBinaryTranslation.Instance.Write( writer, item.FormKey, header); }
/// <summary> /// Attempts to locate link's winning target record in given Link Cache. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <param name="majorRecord">Major Record if located</param> /// <returns>True if successful in linking to record</returns> /// <typeparam name="TMajor">Major Record type to resolve to</typeparam> public static bool TryResolve <TMajor>(this IFormLinkGetter <TMajor> link, ILinkCache cache, [MaybeNullWhen(false)] out TMajor majorRecord) where TMajor : class, IMajorRecordGetter { if (link.FormKeyNullable is not { } formKey) { majorRecord = default; return(false); } return(cache.TryResolve <TMajor>(formKey, out majorRecord)); }
public bool Equals(IFormLinkGetter <TMajorGetter>?x, IFormLinkGetter <TMajorGetter>?y) { if (x == null && y == null) { return(true); } if (x == null || y == null) { return(false); } return(x.FormKey == y.FormKey); }
public override bool TryResolveContext <TMajor, TMajorGetter>(IFormLinkGetter <TMajorGetter> formLink, ILinkCache <ISkyrimMod, ISkyrimModGetter> cache, [MaybeNullWhen(false)] out IModContext context) { if (formLink.TryResolveSimpleContext <TMajorGetter>(cache, out var resolved)) { context = resolved; return(true); } context = default; return(false); }
/// <summary> /// Locates link winning target record in given Link Cache. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Located Major Record</returns> /// <exception cref="NullReferenceException">If link was not succesful</exception> /// <typeparam name="TMajor">Major Record type to resolve to</typeparam> public static TMajor?TryResolve <TMajor>(this IFormLinkGetter <TMajor> link, ILinkCache cache) where TMajor : class, IMajorRecordGetter { if (link.FormKeyNullable == null) { return(null); } if (link.TryResolve <TMajor>(cache, out var majorRecord)) { return(majorRecord); } return(null); }
/// <summary> /// Locate all of a link's target record contexts in given Link Cache.<br /> /// The winning override will be returned first, and finished by the original defining definition. /// </summary> /// <param name="link">FormLink to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Enumerable of the linked records</returns> /// <typeparam name="TMajor">Original links Major Record type</typeparam> /// <typeparam name="TScoped">Inheriting Major Record type to scope to</typeparam> public static IEnumerable <IModContext <TScoped> > ResolveAllSimpleContexts <TMajor, TScoped>( this IFormLinkGetter <TMajor> link, ILinkCache cache) where TMajor : class, IMajorRecordGetter where TScoped : class, TMajor { if (link.FormKeyNullable is not { } formKey) { return(Enumerable.Empty <IModContext <TScoped> >()); } return(cache.ResolveAllSimpleContexts <TScoped>(formKey)); }
public bool Parse <T>( MutagenFrame frame, [MaybeNullWhen(false)] out IFormLinkGetter <T> item) where T : class, IMajorRecordCommonGetter { if (FormKeyBinaryTranslation.Instance.Parse(frame, out FormKey id)) { item = new FormLink <T>(id); return(true); } item = new FormLink <T>(); return(false); }
/// <summary> /// Locates link winning target record in given Link Cache. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Located Major Record</returns> /// <exception cref="RecordException">If link was not succesful</exception> /// <typeparam name="TMajor">Major Record type of the FormLink</typeparam> public static TMajor Resolve <TMajor>(this IFormLinkGetter link, ILinkCache cache) where TMajor : class, IMajorRecordCommonGetter { if (link.TryResolve <TMajor>(cache, out var majorRecord)) { return(majorRecord); } throw RecordException.Create <TMajor>( message: "Could not resolve record", formKey: link.FormKeyNullable, modKey: link.FormKeyNullable?.ModKey, edid: null); }
/// <summary> /// Checks if a Keyworded record contains a specific Keyword, by FormKey. /// Also looks up that keyword in the given cache. <br /> /// <br /> /// Note that this function only succeeds if the record contains the keyword, /// and the cache found it as well. <br /> /// <br /> /// It is possible that the record contains the keyword, but it could not be found /// by the cache. /// <br /> /// Aspects: IKeywordedGetter<IKeywordCommonGetter> /// </summary> /// <param name="keyworded">Keyworded record to check</param> /// <param name="keywordLink">FormLink of the Keyword record to look for</param> /// <param name="cache">LinkCache to resolve against</param> /// <param name="keyword">Keyword record retrieved, if keyworded record does contain</param> /// <returns>True if the Keyworded record contains a Keyword link /w the given FormKey</returns> public static bool TryResolveKeyword <TKeyword>( this IKeywordedGetter <TKeyword> keyworded, IFormLinkGetter <TKeyword> keywordLink, ILinkCache cache, [MaybeNullWhen(false)] out TKeyword keyword) where TKeyword : class, IKeywordCommonGetter { if (!keyworded.Keywords?.Any(x => x.FormKey == keywordLink.FormKey) ?? true) { keyword = default; return(false); } return(keywordLink.TryResolve <TKeyword>(cache, out keyword)); }
/// <summary> /// Locate all of a link's target record contexts in given Link Cache.<br /> /// The winning override will be returned first, and finished by the original defining definition. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Enumerable of the linked records</returns> /// <typeparam name="TMod">Mod setter type that can be overridden into</typeparam> /// <typeparam name="TModGetter">Mod getter type that can be overridden into</typeparam> /// <typeparam name="TMajor">Major Record setter type to resolve to</typeparam> /// <typeparam name="TMajorGetter">Major Record getter type to resolve to</typeparam> public static IEnumerable <IModContext <TMod, TModGetter, TMajor, TMajorGetter> > ResolveAllContexts <TMod, TModGetter, TMajor, TMajorGetter>( this IFormLinkGetter <TMajorGetter> link, ILinkCache <TMod, TModGetter> cache) where TModGetter : class, IModGetter where TMod : class, TModGetter, IContextMod <TMod, TModGetter> where TMajor : class, IMajorRecordCommon, TMajorGetter where TMajorGetter : class, IMajorRecordCommonGetter { if (!link.FormKeyNullable.TryGet(out var formKey)) { return(Enumerable.Empty <IModContext <TMod, TModGetter, TMajor, TMajorGetter> >()); } return(cache.ResolveAllContexts <TMajor, TMajorGetter>(formKey)); }
/// <summary> /// Locates link winning target record in given Link Cache. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Located Major Record</returns> /// <exception cref="NullReferenceException">If link was not succesful</exception> /// <typeparam name="TMod">Mod setter type that can be overridden into</typeparam> /// <typeparam name="TModGetter">Mod getter type that can be overridden into</typeparam> /// <typeparam name="TMajor">Major Record setter type to resolve to</typeparam> /// <typeparam name="TMajorGetter">Major Record getter type to resolve to</typeparam> public static IModContext <TMod, TModGetter, TMajor, TMajorGetter>?ResolveContext <TMod, TModGetter, TMajor, TMajorGetter>( this IFormLinkGetter <TMajorGetter> link, ILinkCache <TMod, TModGetter> cache) where TModGetter : class, IModGetter where TMod : class, TModGetter, IContextMod <TMod, TModGetter> where TMajor : class, IMajorRecordCommon, TMajorGetter where TMajorGetter : class, IMajorRecordCommonGetter { if (link.TryResolveContext <TMod, TModGetter, TMajor, TMajorGetter>(cache, out var majorRecord)) { return(majorRecord); } return(null); }
/// <summary> /// Attempts to winning locate link target record in given Link Cache. /// </summary> /// <param name="link">FormLink to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <param name="majorRecord">Located record if successful</param> /// <returns>True if link was resolved and a record was retrieved</returns> /// <typeparam name="TMajor">Original links Major Record type</typeparam> /// <typeparam name="TScoped">Inheriting Major Record type to scope to</typeparam> public static bool TryResolveSimpleContext <TMajor, TScoped>( this IFormLinkGetter <TMajor> link, ILinkCache cache, [MaybeNullWhen(false)] out IModContext <TScoped> majorRecord) where TMajor : class, IMajorRecordGetter where TScoped : class, TMajor { if (link.FormKeyNullable is not { } formKey) { majorRecord = default; return(false); } return(cache.TryResolveSimpleContext <TScoped>(formKey, out majorRecord)); }
/// <summary> /// Locate all of a link's target record contexts in given Link Cache.<br /> /// The winning override will be returned first, and finished by the original defining definition. /// </summary> /// <param name="link">FormLink to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <returns>Enumerable of the linked records</returns> /// <typeparam name="TMod">Mod setter type that can be overridden into</typeparam> /// <typeparam name="TModGetter">Mod getter type that can be overridden into</typeparam> /// <typeparam name="TMajorGetter">Original links Major Record type</typeparam> /// <typeparam name="TScopedSetter">Inheriting Major Record setter type to scope to</typeparam> /// <typeparam name="TScopedGetter">Inheriting Major Record getter type to scope to</typeparam> public static IEnumerable <IModContext <TMod, TModGetter, TScopedSetter, TScopedGetter> > ResolveAllContexts <TMod, TModGetter, TMajorGetter, TScopedSetter, TScopedGetter>( this IFormLinkGetter <TMajorGetter> link, ILinkCache <TMod, TModGetter> cache) where TModGetter : class, IModGetter where TMod : class, TModGetter, IContextMod <TMod, TModGetter> where TMajorGetter : class, IMajorRecordGetter where TScopedSetter : class, TScopedGetter, IMajorRecord where TScopedGetter : class, TMajorGetter { if (link.FormKeyNullable is not { } formKey) { return(Enumerable.Empty <IModContext <TMod, TModGetter, TScopedSetter, TScopedGetter> >()); } return(cache.ResolveAllContexts <TScopedSetter, TScopedGetter>(formKey)); }
internal static bool EqualsWithInheritanceConsideration <TMajorGetter>(IFormLinkGetter <TMajorGetter> link, object?obj) where TMajorGetter : class, IMajorRecordCommonGetter { if (obj == null) { return(link.IsNull); } else if (obj is IFormLinkGetter <TMajorGetter> rhs) { return(link.FormKey == rhs.FormKey); } else if (obj is IFormLinkGetter rhsLink && rhsLink.Type.IsAssignableFrom(typeof(TMajorGetter))) { return(link.FormKey == rhsLink.FormKey); }
/// <summary> /// Attempts to locate link's winning target record in given Link Cache. /// </summary> /// <param name="link">Link to resolve</param> /// <param name="cache">Link Cache to resolve against</param> /// <param name="majorRecord">Major Record if located</param> /// <returns>True if successful in linking to record</returns> /// <typeparam name="TMod">Mod setter type that can be overridden into</typeparam> /// <typeparam name="TModGetter">Mod getter type that can be overridden into</typeparam> /// <typeparam name="TMajor">Major Record setter type to resolve to</typeparam> /// <typeparam name="TMajorGetter">Major Record getter type to resolve to</typeparam> public static bool TryResolveContext <TMod, TModGetter, TMajor, TMajorGetter>( this IFormLinkGetter <TMajorGetter> link, ILinkCache <TMod, TModGetter> cache, [MaybeNullWhen(false)] out IModContext <TMod, TModGetter, TMajor, TMajorGetter> majorRecord) where TModGetter : class, IModGetter where TMod : class, TModGetter, IContextMod <TMod, TModGetter> where TMajor : class, IMajorRecordCommon, TMajorGetter where TMajorGetter : class, IMajorRecordCommonGetter { if (!link.FormKeyNullable.TryGet(out var formKey)) { majorRecord = default; return(false); } return(cache.TryResolveContext <TMajor, TMajorGetter>(formKey, out majorRecord)); }
public void ClassifyIngredient(IFormLinkGetter <IItemGetter> itemLink) { if (DoNotUnburdenFormKeys.Contains(itemLink)) { return; } if (!itemLink.TryResolve(LinkCache, out var record)) { return; } if (record is IIngredientGetter || record is IIngestibleGetter) { IngredientSet.Add(itemLink); } if (ShouldUnburden(record)) { AllSet.Add(itemLink); SpecificSet.Add(itemLink); } }
public static void FormLink() { var mod = new SkyrimMod(Utility.LightMasterModKey, SkyrimRelease.SkyrimLE); var light = mod.Lights.AddNew(); var cache = mod.ToImmutableLinkCache(); var link = new FormLink <ISkyrimMajorRecordGetter>(light.FormKey); var nullableLink = new FormLinkNullable <ISkyrimMajorRecordGetter>(light.FormKey); IFormLinkGetter <ISkyrimMajorRecordGetter> iLink = link; // Normal resolution link.TryResolve(cache, out var _); link.TryResolve <ISkyrimMajorRecordGetter>(cache, out var _); link.Resolve(cache); link.TryResolve <ILightGetter>(cache, out var _); link.TryResolve(cache, out ILightGetter _); link.Resolve <ILightGetter>(cache); nullableLink.TryResolve(cache, out var _); nullableLink.TryResolve <ISkyrimMajorRecordGetter>(cache, out var _); nullableLink.Resolve(cache); nullableLink.TryResolve <ILightGetter>(cache, out var _); nullableLink.TryResolve(cache, out ILightGetter _); nullableLink.Resolve <ILightGetter>(cache); iLink.TryResolve(cache, out var _); iLink.Resolve(cache); iLink.TryResolve <ISkyrimMajorRecordGetter, ILightGetter>(cache, out var _); iLink.TryResolve(cache, out ILightGetter _); iLink.Resolve <ISkyrimMajorRecordGetter, ILightGetter>(cache); // Context resolution link.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _); link.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _); link.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache); link.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _); link.TryResolveContext(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ILight, ILightGetter> _); link.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache); nullableLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _); nullableLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _); nullableLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache); nullableLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _); nullableLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ILight, ILightGetter> _); nullableLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache); iLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _); iLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache); iLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _); iLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ILight, ILightGetter> _); iLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache); // Getter interface conversion IPerkGetter getter = new Perk(Utility.Form1, SkyrimRelease.SkyrimLE); Perk direct = new Perk(Utility.Form2, SkyrimRelease.SkyrimLE); IPerk setter = new Perk(Utility.Form2, SkyrimRelease.SkyrimLE); IFormLink <IPerkGetter> formLink = new FormLink <IPerkGetter>(); formLink = getter.AsLink(); formLink = direct.AsLink(); formLink = setter.AsLink(); formLink.SetTo(direct); formLink.SetTo(getter); formLink.SetTo(setter); formLink.SetTo(formLink); IObjectEffectGetter objGetter = null !; IFormLink <IEffectRecordGetter> aLink = new FormLink <IEffectRecordGetter>(); aLink.SetTo(objGetter); IFormLink <ISkyrimMajorRecordGetter> majRecordLink = new FormLink <ISkyrimMajorRecordGetter>(); IFormLink <IKeywordGetter> keywordLink = new FormLink <IKeywordGetter>(); majRecordLink.SetTo(keywordLink); majRecordLink.TryResolve <IKeywordGetter>(cache, out var keyw); }
public override IEnumerable <IModContext> ResolveAllContexts <TMajorGetter, TScopedSetter, TScopedGetter>(IFormLinkGetter <TMajorGetter> formLink, ILinkCache <ISkyrimMod, ISkyrimModGetter> cache) { return(formLink.ResolveAllSimpleContexts <TMajorGetter, TScopedGetter>(cache)); }
/// <summary> /// Takes in a FormLink, and either returns the existing override definition /// from the Group, or attempts to link and copy the given record, inserting it, and then returning it as an override. /// </summary> /// <param name="group">Group to retrieve and/or insert from</param> /// <param name="link">Link to query and add</param> /// <param name="cache">Cache to query link against</param> /// <returns>Retrieved record if successful</returns> public static TMajor GetOrAddAsOverride <TMajor, TMajorGetter>(this IGroup <TMajor> group, IFormLinkGetter <TMajorGetter> link, ILinkCache cache) where TMajor : class, IMajorRecordInternal, TMajorGetter where TMajorGetter : class, IMajorRecordGetter { if (TryGetOrAddAsOverride(group, link, cache, out var rec)) { return(rec); } throw new MissingRecordException(link.FormKey, link.Type); }
public int GetHashCode(IFormLinkGetter <TMajorGetter> obj) { return(obj.GetHashCode()); }
/// <summary> /// Compares equality of two links, where rhs is a non nullable link. /// </summary> /// <param name="other">Other link to compare to</param> /// <returns>True if FormKey members are equal</returns> public bool Equals(IFormLinkGetter <TMajorGetter>?other) => EqualityComparer <FormKey?> .Default.Equals(this._formKey, other?.FormKey);
/// <summary> /// Takes in a FormLink, and either returns the existing override definition /// from the Group, or attempts to link and copy the given record, inserting it, and then returning it as an override. /// </summary> /// <param name="group">Group to retrieve and/or insert from</param> /// <param name="link">Link to query and add</param> /// <param name="cache">Cache to query link against</param> /// <param name="rec">Retrieved record if successful</param> /// <returns>True if a record was retrieved</returns> public static bool TryGetOrAddAsOverride <TMajor, TMajorGetter>(this IGroup <TMajor> group, IFormLinkGetter <TMajorGetter> link, ILinkCache cache, [MaybeNullWhen(false)] out TMajor rec) where TMajor : class, IMajorRecordInternal, TMajorGetter where TMajorGetter : class, IMajorRecordGetter { try { if (group.RecordCache.TryGetValue(link.FormKey, out rec)) { return(true); } if (!link.TryResolve <TMajorGetter>(cache, out var getter)) { rec = default; return(false); } rec = GetOrAddAsOverride(group, getter); return(true); } catch (Exception ex) { throw RecordException.Enrich <TMajor>(ex, link.FormKey, edid: null); } }