Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
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(IFormLinkNullable <TMajor> other) => EqualityComparer <FormKey?> .Default.Equals(this.FormKey, other.FormKey);
Ejemplo n.º 5
0
 public static IFormLinkNullableGetter <TGetter> AsGetter <TGetter>(this IFormLinkNullable <TGetter> link)
     where TGetter : class, IMajorRecordCommonGetter
 {
     return(link);
 }
Ejemplo n.º 6
0
 public static FormLinkInformation Factory <TMajorGetter>(IFormLinkNullable <TMajorGetter> link)
     where TMajorGetter : IMajorRecordCommonGetter
 {
     return(new FormLinkInformation(link.FormKey, typeof(TMajorGetter)));
 }
Ejemplo n.º 7
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(IFormLinkNullable <TMajorGetter>?other) => EqualityComparer <FormKey?> .Default.Equals(this.FormKey, other?.FormKeyNullable);
Ejemplo n.º 8
0
 /// <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);
 }