Handle ignored mappings locally in `Detach` configuration

This commit is contained in:
Dean Herbert 2022-01-07 22:57:12 +09:00
parent 2b8706b6ce
commit aaefd72c69
3 changed files with 3 additions and 12 deletions

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using osu.Framework.Testing;
using osu.Game.Database;
using osu.Game.Extensions;
@ -76,10 +75,8 @@ public bool Equals(BeatmapSetInfo? other)
public bool Equals(IBeatmapSetInfo? other) => other is BeatmapSetInfo b && Equals(b);
[IgnoreMap]
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
[IgnoreMap]
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => Files;
}
}

View File

@ -22,7 +22,9 @@ public static class RealmObjectExtensions
private static readonly IMapper mapper = new MapperConfiguration(c =>
{
c.ShouldMapField = fi => false;
c.ShouldMapProperty = pi => true;
// If we want to limit this further, we can avoid mapping properties with no setter that are not IList<>.
// Takes a bit of effort to determine whether this is the case though, see https://stackoverflow.com/questions/951536/how-do-i-tell-whether-a-type-implements-ilist
c.ShouldMapProperty = pi => pi.GetMethod?.IsPublic == true;
c.CreateMap<RealmKeyBinding, RealmKeyBinding>();
c.CreateMap<BeatmapMetadata, BeatmapMetadata>();

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using Newtonsoft.Json;
using osu.Framework.Localisation;
using osu.Framework.Testing;
@ -113,16 +112,9 @@ public ScoreRank Rank
[MapTo(nameof(Rank))]
public int RankInt { get; set; }
[IgnoreMap]
IRulesetInfo IScoreInfo.Ruleset => Ruleset;
[IgnoreMap]
IBeatmapInfo IScoreInfo.Beatmap => Beatmap;
[IgnoreMap]
IUser IScoreInfo.User => User;
[IgnoreMap]
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => Files;
#region Properties required to make things work with existing usages