Re-write
This commit is contained in:
41
Shared/Models/Container.cs
Normal file
41
Shared/Models/Container.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public class Container : Properties.IContainer
|
||||
{
|
||||
|
||||
protected readonly int _G;
|
||||
protected readonly int _R;
|
||||
protected readonly List<Item> _Items;
|
||||
protected readonly string _SourceDirectory;
|
||||
public int G => _G;
|
||||
public List<Item> Items => _Items;
|
||||
public int R => _R;
|
||||
public string SourceDirectory => _SourceDirectory;
|
||||
|
||||
[JsonConstructor]
|
||||
public Container(int g, int r, List<Item> items, string sourceDirectory)
|
||||
{
|
||||
_G = g;
|
||||
_R = r;
|
||||
_Items = items;
|
||||
_SourceDirectory = sourceDirectory;
|
||||
}
|
||||
|
||||
public Container(int g, int r, string sourceDirectory)
|
||||
{
|
||||
_G = g;
|
||||
_R = r;
|
||||
_Items = new();
|
||||
_SourceDirectory = sourceDirectory;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user