예제 #1
0
 /// <summary>
 /// Takes in an existing record definition, and either returns the existing override definition
 /// from the Group, or copies the given record, inserts it, and then returns it as an override.
 /// </summary>
 /// <param name="group">Group to retrieve and/or insert from</param>
 /// <param name="major">Major record to query and potentially copy</param>
 /// <returns>Existing override record, or a copy of the given record that has already been inserted into the group</returns>
 public static TMajor GetOrAddAsOverride <TMajor, TMajorGetter>(this IGroup <TMajor> group, TMajorGetter major)
     where TMajor : class, IMajorRecordInternal, TMajorGetter
     where TMajorGetter : class, IMajorRecordGetter
 {
     try
     {
         if (group.RecordCache.TryGetValue(major.FormKey, out var existingMajor))
         {
             return(existingMajor);
         }
         var mask = OverrideMaskRegistrations.Get <TMajor>();
         existingMajor = (major.DeepCopy(mask as MajorRecord.TranslationMask) as TMajor) !;
         group.RecordCache.Set(existingMajor);
         return(existingMajor);
     }
     catch (Exception ex)
     {
         throw RecordException.Enrich <TMajor>(ex, major.FormKey, major.EditorID);
     }
 }
예제 #2
0
 static partial void InitCustom()
 {
     OverrideMaskRegistrations.Warmup();
 }