From 81d6f268eef9ed2945c3e84dd7ee2da939017f0c Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Wed, 23 Aug 2023 08:09:05 +0200 Subject: [PATCH] Cleanup --- Influx/Influx.csproj | 8 ++--- Influx/SubmarineTracker/FcSubmarines.cs | 21 +++++++++++++ Influx/SubmarineTracker/Submarine.cs | 16 ++++++++++ .../SubmarineTracker/SubmarineTrackerIpc.cs | 31 ------------------- 4 files changed, 41 insertions(+), 35 deletions(-) create mode 100644 Influx/SubmarineTracker/FcSubmarines.cs create mode 100644 Influx/SubmarineTracker/Submarine.cs diff --git a/Influx/Influx.csproj b/Influx/Influx.csproj index 455bd8e..ee08837 100644 --- a/Influx/Influx.csproj +++ b/Influx/Influx.csproj @@ -22,8 +22,8 @@ - - + + @@ -58,10 +58,10 @@ - + - + diff --git a/Influx/SubmarineTracker/FcSubmarines.cs b/Influx/SubmarineTracker/FcSubmarines.cs new file mode 100644 index 0000000..6e5ac6e --- /dev/null +++ b/Influx/SubmarineTracker/FcSubmarines.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Influx.SubmarineTracker; + +public sealed class FcSubmarines +{ + private readonly object _delegate; + + public FcSubmarines(object @delegate) + { + _delegate = @delegate; + Submarines = ((IEnumerable)_delegate.GetType().GetField("Submarines")!.GetValue(_delegate)!) + .Cast() + .Select(x => new Submarine(x)) + .ToList(); + } + + public List Submarines { get; } +} diff --git a/Influx/SubmarineTracker/Submarine.cs b/Influx/SubmarineTracker/Submarine.cs new file mode 100644 index 0000000..7cdd10d --- /dev/null +++ b/Influx/SubmarineTracker/Submarine.cs @@ -0,0 +1,16 @@ +namespace Influx.SubmarineTracker; + +public sealed class Submarine +{ + private readonly object _delegate; + + public Submarine(object @delegate) + { + _delegate = @delegate; + Name = (string)_delegate.GetType().GetProperty("Name")!.GetValue(_delegate)!; + Level = (ushort)_delegate.GetType().GetProperty("Rank")!.GetValue(_delegate)!; + } + + public string Name { get; set; } + public ushort Level { get; } +} diff --git a/Influx/SubmarineTracker/SubmarineTrackerIpc.cs b/Influx/SubmarineTracker/SubmarineTrackerIpc.cs index aac78e2..b1d41ab 100644 --- a/Influx/SubmarineTracker/SubmarineTrackerIpc.cs +++ b/Influx/SubmarineTracker/SubmarineTrackerIpc.cs @@ -53,34 +53,3 @@ internal sealed class SubmarineTrackerIpc return new Dictionary>(); } } - -public sealed class FcSubmarines -{ - private readonly object _delegate; - - public FcSubmarines(object @delegate) - { - _delegate = @delegate; - Submarines = ((IEnumerable)_delegate.GetType().GetField("Submarines")!.GetValue(_delegate)!) - .Cast() - .Select(x => new Submarine(x)) - .ToList(); - } - - public List Submarines { get; } -} - -public sealed class Submarine -{ - private readonly object _delegate; - - public Submarine(object @delegate) - { - _delegate = @delegate; - Name = (string)_delegate.GetType().GetProperty("Name")!.GetValue(_delegate)!; - Level = (ushort)_delegate.GetType().GetProperty("Rank")!.GetValue(_delegate)!; - } - - public string Name { get; set; } - public ushort Level { get; } -}