mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Update automapper spec in line with v11
See https://docs.automapper.org/en/latest/11.0-Upgrade-Guide.html for more details.
This commit is contained in:
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AutoMapper;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
@ -37,7 +36,6 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public BeatmapMetadata Metadata { get; set; }
|
public BeatmapMetadata Metadata { get; set; }
|
||||||
|
|
||||||
[IgnoreMap]
|
|
||||||
[Backlink(nameof(ScoreInfo.BeatmapInfo))]
|
[Backlink(nameof(ScoreInfo.BeatmapInfo))]
|
||||||
public IQueryable<ScoreInfo> Scores { get; } = null!;
|
public IQueryable<ScoreInfo> Scores { get; } = null!;
|
||||||
|
|
||||||
@ -155,7 +153,6 @@ namespace osu.Game.Beatmaps
|
|||||||
#region Compatibility properties
|
#region Compatibility properties
|
||||||
|
|
||||||
[Ignored]
|
[Ignored]
|
||||||
[IgnoreMap]
|
|
||||||
public int RulesetID
|
public int RulesetID
|
||||||
{
|
{
|
||||||
get => Ruleset.OnlineID;
|
get => Ruleset.OnlineID;
|
||||||
@ -169,7 +166,6 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Ignored]
|
[Ignored]
|
||||||
[IgnoreMap]
|
|
||||||
public BeatmapDifficulty BaseDifficulty
|
public BeatmapDifficulty BaseDifficulty
|
||||||
{
|
{
|
||||||
get => Difficulty;
|
get => Difficulty;
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using AutoMapper.Internal;
|
||||||
using osu.Framework.Development;
|
using osu.Framework.Development;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
@ -60,7 +62,14 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
c.AddGlobalIgnore(nameof(RealmObjectBase.ObjectSchema));
|
c.Internal().ForAllMaps((typeMap, expression) =>
|
||||||
|
{
|
||||||
|
expression.ForAllMembers(m =>
|
||||||
|
{
|
||||||
|
if (m.DestinationMember.Has<IgnoredAttribute>() || m.DestinationMember.Has<BacklinkAttribute>() || m.DestinationMember.Has<IgnoreDataMemberAttribute>())
|
||||||
|
m.Ignore();
|
||||||
|
});
|
||||||
|
});
|
||||||
}).CreateMapper();
|
}).CreateMapper();
|
||||||
|
|
||||||
private static readonly IMapper mapper = new MapperConfiguration(c =>
|
private static readonly IMapper mapper = new MapperConfiguration(c =>
|
||||||
@ -80,7 +89,9 @@ namespace osu.Game.Database
|
|||||||
c.CreateMap<RealmUser, RealmUser>();
|
c.CreateMap<RealmUser, RealmUser>();
|
||||||
c.CreateMap<RealmFile, RealmFile>();
|
c.CreateMap<RealmFile, RealmFile>();
|
||||||
c.CreateMap<RealmNamedFileUsage, RealmNamedFileUsage>();
|
c.CreateMap<RealmNamedFileUsage, RealmNamedFileUsage>();
|
||||||
c.CreateMap<BeatmapInfo, BeatmapInfo>().MaxDepth(2).AfterMap((s, d) =>
|
c.CreateMap<BeatmapInfo, BeatmapInfo>()
|
||||||
|
.MaxDepth(2)
|
||||||
|
.AfterMap((s, d) =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d.BeatmapSet?.Beatmaps.Count; i++)
|
for (int i = 0; i < d.BeatmapSet?.Beatmaps.Count; i++)
|
||||||
{
|
{
|
||||||
@ -91,13 +102,22 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>().MaxDepth(2).AfterMap((s, d) =>
|
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
||||||
|
.MaxDepth(2)
|
||||||
|
.AfterMap((s, d) =>
|
||||||
{
|
{
|
||||||
foreach (var beatmap in d.Beatmaps)
|
foreach (var beatmap in d.Beatmaps)
|
||||||
beatmap.BeatmapSet = d;
|
beatmap.BeatmapSet = d;
|
||||||
});
|
});
|
||||||
|
|
||||||
c.AddGlobalIgnore(nameof(RealmObjectBase.ObjectSchema));
|
c.Internal().ForAllMaps((typeMap, expression) =>
|
||||||
|
{
|
||||||
|
expression.ForAllMembers(m =>
|
||||||
|
{
|
||||||
|
if (m.DestinationMember.Has<IgnoredAttribute>() || m.DestinationMember.Has<BacklinkAttribute>() || m.DestinationMember.Has<IgnoreDataMemberAttribute>())
|
||||||
|
m.Ignore();
|
||||||
|
});
|
||||||
|
});
|
||||||
}).CreateMapper();
|
}).CreateMapper();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AutoMapper;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -85,7 +84,7 @@ namespace osu.Game.Scoring
|
|||||||
// Eventually we should either persist enough information to realm to not require the API lookups, or perform the API lookups locally.
|
// Eventually we should either persist enough information to realm to not require the API lookups, or perform the API lookups locally.
|
||||||
private APIUser? user;
|
private APIUser? user;
|
||||||
|
|
||||||
[IgnoreMap]
|
[Ignored]
|
||||||
public APIUser User
|
public APIUser User
|
||||||
{
|
{
|
||||||
get => user ??= new APIUser
|
get => user ??= new APIUser
|
||||||
|
Reference in New Issue
Block a user