/// <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="TMajorSetter">Major Record setter type to resolve to</typeparam> /// <typeparam name="TMajorGetter">Major Record getter type to resolve to</typeparam> public static IEnumerable <IModContext <TMod, TMajorSetter, TMajorGetter> > ResolveAllContexts <TMod, TMajorSetter, TMajorGetter>(this IFormLink <TMajorGetter> link, ILinkCache <TMod> cache) where TMod : class, IContextMod <TMod> where TMajorSetter : class, IMajorRecordCommon, TMajorGetter where TMajorGetter : class, IMajorRecordCommonGetter { if (!link.FormKeyNullable.TryGet(out var formKey)) { return(Enumerable.Empty <IModContext <TMod, TMajorSetter, TMajorGetter> >()); } return(cache.ResolveAllContexts <TMajorSetter, TMajorGetter>(formKey)); }
/// <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, IMajorRecord, TMajorGetter where TMajorGetter : class, IMajorRecordGetter { if (link.FormKeyNullable is not { } formKey) { return(Enumerable.Empty <IModContext <TMod, TModGetter, TMajor, TMajorGetter> >()); } return(cache.ResolveAllContexts <TMajor, TMajorGetter>(formKey)); }