public static IFormLinkNullable <TMajorGetter> Relink <TMajorGetter>(this IFormLinkNullable <TMajorGetter> link, IReadOnlyDictionary <FormKey, FormKey> mapping) where TMajorGetter : class, IMajorRecordCommonGetter { if (link.FormKeyNullable.HasValue && !link.IsNull && mapping.TryGetValue(link.FormKey, out var replacement)) { return(new FormLinkNullable <TMajorGetter>(replacement)); } return(link); }
public bool Parse <T>( MutagenFrame frame, [MaybeNullWhen(false)] out IFormLinkNullable <T> item) where T : class, IMajorRecordCommonGetter { if (FormKeyBinaryTranslation.Instance.Parse(frame, out FormKey id)) { item = new FormLinkNullable <T>(id); return(true); } item = new FormLinkNullable <T>(); return(false); }
public void WriteNullable <T>( MutagenWriter writer, IFormLinkNullable <T> item) where T : class, IMajorRecordCommonGetter { if (item.FormKey == null) { return; } FormKeyBinaryTranslation.Instance.Write( writer, item.FormKey.Value); }
/// <summary> /// Compares equality of two links, where rhs is a nullable link. /// </summary> /// <param name="other">Other link to compare to</param> /// <returns>True if FormKey members are equal</returns> public bool Equals(IFormLinkNullable <TMajor> other) => EqualityComparer <FormKey?> .Default.Equals(this.FormKey, other.FormKey);
public static IFormLinkNullableGetter <TGetter> AsGetter <TGetter>(this IFormLinkNullable <TGetter> link) where TGetter : class, IMajorRecordCommonGetter { return(link); }
public static FormLinkInformation Factory <TMajorGetter>(IFormLinkNullable <TMajorGetter> link) where TMajorGetter : IMajorRecordCommonGetter { return(new FormLinkInformation(link.FormKey, typeof(TMajorGetter))); }
/// <summary> /// Compares equality of two links, where rhs is a nullable link. /// </summary> /// <param name="other">Other link to compare to</param> /// <returns>True if FormKey members are equal</returns> public bool Equals(IFormLinkNullable <TMajorGetter>?other) => EqualityComparer <FormKey?> .Default.Equals(this.FormKey, other?.FormKeyNullable);
/// <summary> /// Attempts to locate link target in given Link Cache. /// </summary> /// <param name="formLink">FormLink to resolve</param> /// <param name="package">Link Cache to resolve against</param> /// <param name="major">Located record if successful</param> /// <returns>True if link was resolved and a record was retrieved</returns> /// <typeparam name="TMod">Mod type</typeparam> /// <typeparam name="TMajor">Major Record type to resolve to</typeparam> public static bool TryResolve <TMajor>(this IFormLinkNullable <TMajor> formLink, ILinkCache package, out TMajor major) where TMajor : IMajorRecordCommonGetter { major = formLink.Resolve(package); return(major != null); }