Commit Graph

31 Commits

Author SHA1 Message Date
Dan Balasescu f8830c6850 Automated #nullable processing 2022-06-17 16:37:17 +09:00
Dean Herbert 7d11cfb301 Add detach mapping for `BeatmapUserSettings` 2022-03-01 20:12:59 +09:00
Bartłomiej Dach dc96c4888b
Add support for creating new blank difficulties 2022-02-02 21:55:33 +01:00
Dean Herbert 45636ce04b Remove collection `ToLive` helper method to avoid confusion 2022-01-26 18:26:37 +09:00
Dean Herbert cd71ec0edd Remove `ILive<>` interface (and use `abstract Live<>` instead) 2022-01-26 13:38:56 +09:00
Dean Herbert 6eb2c28e41 Rename `RealmContextFactory` to `RealmAccess` 2022-01-24 20:38:07 +09:00
Dean Herbert 40aa873190 Rename register methods to better explain their purpose 2022-01-24 14:37:36 +09:00
Dean Herbert 18bf690a30 Add `Register` method for subscription purposes and update safeties 2022-01-21 19:06:18 +09:00
Dean Herbert ccddf9b47d Avoid constructor overhead for realm `BeatmapSetInfo` parameterless constructor 2022-01-20 17:03:44 +09:00
Dan Balasescu 2556f1cb87
Merge branch 'master' into optimise-set-detach-part-2 2022-01-19 13:20:38 +09:00
Dean Herbert 761e161eec Add comment explaining ignore rule 2022-01-19 09:44:21 +09:00
Dean Herbert 60b80c88b6 Avoid file retrieval overhead when detaching `BeatmapSetInfo`
It seems that no usages of `BeatmapSetInfo` detaches require files - a
`WorkingBeatmap` is always obtained before doing further lookups.

Therefore we can omit this include unless the detaching object is a
`BeatmapInfo`. A refetch is performed when retrieving a
`WorkingBeatmap` to complete the equation.
2022-01-19 00:49:18 +09:00
Dean Herbert f2b151023e Create separate automapper configurations to reduce cyclic detach overhead
This optimises the `BeatmapSetInfo` detach operation by avoiding
detaching `BeatmapSetInfo.Beatmaps[].BeatmapSetInfo` a second time over.
2022-01-19 00:03:24 +09:00
Dean Herbert 9a43ed742b Update automapper spec in line with v11
See https://docs.automapper.org/en/latest/11.0-Upgrade-Guide.html for
 more details.
2022-01-18 15:23:28 +09:00
Dean Herbert 085893c9b4 Fix stray bracket 2022-01-13 13:03:57 +09:00
Dean Herbert f24b2b1be3 Make copying detached changes to realm only exposed for `BeatmapSet`
Also fixes remaining issues with the copy process.
2022-01-12 17:49:11 +09:00
Dean Herbert 580ad03f8d Combine mapper configurations and add more explanation about special cases 2022-01-12 17:49:11 +09:00
Salman Ahmed 6db3c32dd1 Handle automapper realm cyclic references via `AfterMap`s
This may not be the cleanest solution, but there don't seem to be any
way towards this either.

- `UseDestinationValue` has been inherited by default as noted in
https://docs.automapper.org/en/stable/10.0-Upgrade-Guide.html#usedestinationvalue-is-now-inherited-by-default, and its behaviour in this case would be using the nested **managed** realm object for the destination member rather than creating an unmanaged version.

- `MaxDepth` already sets `PreserveReferences` so there's no point of using it.

- `MaxDepth` should probably not be set for all maps, only for those with
cyclic references, to avoid the expensive overhead of `PreserveReferences`, as mentioned in https://docs.automapper.org/en/stable/5.0-Upgrade-Guide.html#circular-references.

That aside, `MaxDepth` should actually only be set to `1` for
`BeatmapSetInfo` mapping, because we don't want AutoMapper to create a
nested instance of `BeatmapSetInfo` in each mapped/detached beatmap, but
for some reason, doing that will cause automapper to not map any beatmap
inside the set and leave it with 0 beatmaps.

While on the other hand, using `MaxDepth(2)` for `BeatmapSetInfo` works,
but creates an unused instance of a `BeatmapSetInfo` inside each mapped
beatmap, which may not be ideal.

For `BeatmapInfo`, it has to be `MaxDepth(2)`, in which the first
`BeatmapInfo` depth would be itself (when detaching a beatmap), and the
second would be nested beatmaps inside the mapped/detached
`BeatmapSetInfo` within the beatmap. (note that when detaching a beatmap
set, the unused instance of `BeatmapSetInfo` within each beatmap of that
beatmap set doesn't also have a list of unused beatmaps as one might expect from the depth specification, it surprisingly has 0 beatmaps)

This causes it to create an unused instance of `BeatmapInfo` in the beatmap set resembling the root mapped/detached beatmap, but that one might be inevitable.
2022-01-12 17:49:11 +09:00
Dean Herbert f986c3ebd4 Add basic write support via automapper 2022-01-12 17:49:11 +09:00
Dean Herbert aaefd72c69 Handle ignored mappings locally in `Detach` configuration 2022-01-12 17:00:17 +09:00
Dean Herbert 2b8706b6ce Detach and reattach scores to make work 2022-01-12 17:00:16 +09:00
Dean Herbert 8461eaab46 `BeatmapSetInfo` detach support 2022-01-12 17:00:16 +09:00
Dean Herbert d072f1d08d Add mention to detach methods of only running once 2022-01-10 13:09:26 +09:00
Dean Herbert a9dbcd92a1 Split out unmanaged implementation of `RealmLive` into its own class 2021-12-16 15:23:55 +09:00
Dean Herbert 441b7baa93 Provide a realm factory to usages of `ToLive`/`RealmLive` 2021-12-14 14:26:34 +09:00
Dan Balasescu 685bdd522e Replace 'skin' in comments with 'instance' 2021-12-01 20:17:38 +09:00
Dean Herbert 09817ff161 Add missing `returns` additional documentation to main method call 2021-12-01 15:27:10 +09:00
Dean Herbert 4306420922 Add extension methods to add extra safety to realm subscriptions
Also adjusts the naming and documentation to make it (hopefully) easier
to understand what this method/process implies.
2021-12-01 15:09:53 +09:00
Dean Herbert 21e8ab8357 Return `ILive` from `ToLive` calls instead of realm-typed instance 2021-11-29 14:12:22 +09:00
Dean Herbert b01d82b3fd Add `RealmLive` implementation 2021-10-11 15:36:41 +09:00
Dean Herbert 9fa901f6aa Refine `RealmContext` implementation API 2021-09-30 23:56:38 +09:00