Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 /// <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);
Exemplo n.º 4
0
 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);
 }