public bool Parse <T>( MutagenFrame frame, [MaybeNullWhen(false)] out IFormLinkNullableGetter <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, IFormLinkNullableGetter <T> item) where T : class, IMajorRecordCommonGetter { if (item.FormKeyNullable == null) { return; } FormKeyBinaryTranslation.Instance.Write( writer, item.FormKeyNullable.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(IFormLinkNullableGetter <TMajorGetter>?other) => EqualityComparer <FormKey?> .Default.Equals(this._formKey, other?.FormKeyNullable);
private static IFormLinkNullableGetter <TMajorGetter> RelinkToNew <TMajorGetter>(this IFormLinkNullableGetter <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); }