1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Generic infer for IJsonSerializable.DeepClone.

This commit is contained in:
Huo Yaoyuan 2017-05-08 19:33:37 +08:00
parent 345f80b775
commit e466380ee2
2 changed files with 4 additions and 3 deletions

View File

@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
protected override Beatmap<TaikoHitObject> ConvertBeatmap(Beatmap original) protected override Beatmap<TaikoHitObject> ConvertBeatmap(Beatmap original)
{ {
// Rewrite the beatmap info to add the slider velocity multiplier // Rewrite the beatmap info to add the slider velocity multiplier
BeatmapInfo info = original.BeatmapInfo.DeepClone<BeatmapInfo>(); BeatmapInfo info = original.BeatmapInfo.DeepClone();
info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier; info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier;
Beatmap<TaikoHitObject> converted = base.ConvertBeatmap(original); Beatmap<TaikoHitObject> converted = base.ConvertBeatmap(original);

View File

@ -16,12 +16,13 @@ namespace osu.Game.IO.Serialization
return JsonConvert.SerializeObject(obj); return JsonConvert.SerializeObject(obj);
} }
public static T Deserialize<T>(string objString) public static T Deserialize<T>(this string objString)
{ {
return JsonConvert.DeserializeObject<T>(objString); return JsonConvert.DeserializeObject<T>(objString);
} }
public static T DeepClone<T>(this IJsonSerializable obj) public static T DeepClone<T>(this T obj)
where T : IJsonSerializable
{ {
return Deserialize<T>(Serialize(obj)); return Deserialize<T>(Serialize(obj));
} }