master
Liza 2023-08-23 08:09:05 +02:00
parent b6bd9707b7
commit 81d6f268ee
Signed by: liza
GPG Key ID: 7199F8D727D55F67
4 changed files with 41 additions and 35 deletions

View File

@ -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<object>()
.Select(x => new Submarine(x))
.ToList();
}
public List<Submarine> Submarines { get; }
}

View File

@ -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; }
}

View File

@ -53,34 +53,3 @@ internal sealed class SubmarineTrackerIpc
return new Dictionary<Character, List<SubmarineStats>>();
}
}
public sealed class FcSubmarines
{
private readonly object _delegate;
public FcSubmarines(object @delegate)
{
_delegate = @delegate;
Submarines = ((IEnumerable)_delegate.GetType().GetField("Submarines")!.GetValue(_delegate)!)
.Cast<object>()
.Select(x => new Submarine(x))
.ToList();
}
public List<Submarine> 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; }
}