feat(Documents) Notes/Docs page improvements and warning cleanup
This commit is contained in:
@@ -11,19 +11,17 @@ public class AgileService : IAgileService {
|
||||
private readonly HttpClient httpClient;
|
||||
|
||||
private bool isLoaded;
|
||||
|
||||
|
||||
private event Action _onChange;
|
||||
private event Action OnChange = default!;
|
||||
|
||||
|
||||
public AgileService(HttpClient httpClient) {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
|
||||
#if NO_SQL
|
||||
public List<SprintModel> SprintModels { get; set; }
|
||||
public List<TaskModel> TaskModels { get; set; }
|
||||
public List<AgileSprintModel>? AgileSprintModels { get; set; }
|
||||
public List<AgileTaskModel>? AgileTaskModels { get; set; }
|
||||
#else
|
||||
|
||||
private DatabaseContext Database { get; set; }
|
||||
@@ -32,12 +30,12 @@ public class AgileService : IAgileService {
|
||||
#endif
|
||||
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
public void Subscribe(Action? action) {
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange -= action;
|
||||
public void Unsubscribe(Action? action) {
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public bool IsLoaded() {
|
||||
@@ -50,13 +48,40 @@ public class AgileService : IAgileService {
|
||||
return;
|
||||
}
|
||||
|
||||
SprintModels = (await httpClient.GetFromJsonAsync<SprintModel[]>("generated/SprintModels.json")?? Array.Empty<SprintModel>() ).ToList();
|
||||
TaskModels =(await httpClient.GetFromJsonAsync<TaskModel[]>("generated/TaskModels.json") ?? Array.Empty<TaskModel>()).ToList();
|
||||
|
||||
AgileSprintModels = (await httpClient.GetFromJsonAsync<AgileSprintModel[]>("generated/AgileSprintModels.json")?? Array.Empty<AgileSprintModel>() ).ToList();
|
||||
AgileTaskModels = (await httpClient.GetFromJsonAsync<AgileTaskModel[]>("generated/AgileTaskModels.json") ?? Array.Empty<AgileTaskModel>()).ToList();
|
||||
|
||||
foreach (var agileTask in AgileTaskModels)
|
||||
{
|
||||
if (agileTask.AgileSprintModelId != null)
|
||||
{
|
||||
SprintById(agileTask.AgileSprintModelId.Value)?.AgileTaskModels.Add(agileTask);
|
||||
}
|
||||
}
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
private AgileSprintModel? SprintById(int id)
|
||||
{
|
||||
foreach (var data in AgileSprintModels!)
|
||||
if (data.Id == id)
|
||||
return data;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private AgileTaskModel? TaskById(int id)
|
||||
{
|
||||
foreach (var data in AgileTaskModels!)
|
||||
if (data.Id == id)
|
||||
return data;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#else
|
||||
public async Task Load(DatabaseContext database) {
|
||||
Database = database;
|
||||
@@ -65,8 +90,8 @@ public class AgileService : IAgileService {
|
||||
return;
|
||||
}
|
||||
|
||||
Database.SprintModels.AddRange(await httpClient.GetFromJsonAsync<SprintModel[]>("generated/SprintModels.json"));
|
||||
Database.TaskModels.AddRange(await httpClient.GetFromJsonAsync<TaskModel[]>("generated/TaskModels.json"));
|
||||
Database.SprintModels.AddRange(await httpClient.GetFromJsonAsync<SprintModel[]>("generated/AgileSprintModels.json"));
|
||||
Database.TaskModels.AddRange(await httpClient.GetFromJsonAsync<TaskModel[]>("generated/AgileTaskModels.json"));
|
||||
|
||||
Database.SaveChanges();
|
||||
|
||||
@@ -81,6 +106,6 @@ public class AgileService : IAgileService {
|
||||
}
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Net.Http.Json;
|
||||
using Model.Documentation;
|
||||
using Model.Doc;
|
||||
|
||||
#if NO_SQL
|
||||
|
||||
@@ -13,29 +13,31 @@ namespace Services.Development;
|
||||
public class DocumentationService : IDocumentationService
|
||||
{
|
||||
private readonly HttpClient httpClient;
|
||||
|
||||
private bool isLoaded;
|
||||
|
||||
|
||||
private event Action _onChange;
|
||||
|
||||
|
||||
public DocumentationService(HttpClient httpClient)
|
||||
{
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
public List<DocumentationModel> DocumentationModels { get; set; }
|
||||
public List<DocContentModel> DocContentModels { get; set; } = new();
|
||||
|
||||
public List<DocContentModel> DocContentModelsByPageOrder { get; set; } = new();
|
||||
|
||||
public List<DocSectionModel> DocSectionModels { get; set; } = new();
|
||||
|
||||
public List<DocConnectionModel> DocConnectionModels { get; set; } = new();
|
||||
|
||||
|
||||
public void Subscribe(Action action)
|
||||
|
||||
public void Subscribe(Action? action)
|
||||
{
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action)
|
||||
public void Unsubscribe(Action? action)
|
||||
{
|
||||
_onChange -= action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public bool IsLoaded()
|
||||
@@ -48,9 +50,25 @@ public class DocumentationService : IDocumentationService
|
||||
{
|
||||
if (isLoaded) return;
|
||||
|
||||
DocumentationModels =
|
||||
(await httpClient.GetFromJsonAsync<DocumentationModel[]>("generated/DocumentationModels.json") ?? Array.Empty<DocumentationModel>()).ToList();
|
||||
DocContentModels =
|
||||
(await httpClient.GetFromJsonAsync<DocContentModel[]>("generated/DocContentModels.json") ??
|
||||
Array.Empty<DocContentModel>()).ToList();
|
||||
|
||||
DocConnectionModels =
|
||||
(await httpClient.GetFromJsonAsync<DocConnectionModel[]>("generated/DocConnectionModels.json") ??
|
||||
Array.Empty<DocConnectionModel>()).ToList();
|
||||
|
||||
DocSectionModels =
|
||||
(await httpClient.GetFromJsonAsync<DocSectionModel[]>("generated/DocSectionModels.json") ??
|
||||
Array.Empty<DocSectionModel>()).ToList();
|
||||
|
||||
|
||||
#if DEBUG
|
||||
AddTestCode();
|
||||
#endif
|
||||
|
||||
//TODO Until SQL work in production. Or, why even add SQL?
|
||||
SortSQL();
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
@@ -63,9 +81,108 @@ public class DocumentationService : IDocumentationService
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
private event Action? OnChange;
|
||||
|
||||
private DocContentModel? ContentById(int id)
|
||||
{
|
||||
foreach (var doc in DocContentModels!)
|
||||
if (doc.Id == id)
|
||||
return doc;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void SortSQL()
|
||||
{
|
||||
foreach (var connection in DocConnectionModels)
|
||||
{
|
||||
ContentById(connection.ParentId)!.DocumentationModels.Add(ContentById(connection.ChildId));
|
||||
ContentById(connection.ChildId)!.Parent = ContentById(connection.ParentId);
|
||||
}
|
||||
|
||||
foreach (var content in DocContentModels)
|
||||
{
|
||||
if (content.DocSectionModelId != null)
|
||||
{
|
||||
foreach (var section in DocSectionModels)
|
||||
{
|
||||
if (section.Id == content.DocSectionModelId)
|
||||
{
|
||||
section.DocumentationModels.Add(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ByPageOrder();
|
||||
}
|
||||
|
||||
|
||||
private void ByPageOrder()
|
||||
{
|
||||
DocContentModelsByPageOrder = new List<DocContentModel>();
|
||||
|
||||
int order = 1;
|
||||
foreach (var documentation in DocContentModels)
|
||||
{
|
||||
if (documentation.Parent != null) continue;
|
||||
|
||||
documentation.PageOrder = order++;
|
||||
DocContentModelsByPageOrder.Add(documentation);
|
||||
|
||||
void GetAllChildren(DocContentModel docs)
|
||||
{
|
||||
foreach (var doc in docs.DocumentationModels)
|
||||
{
|
||||
doc.PageOrder = order++;
|
||||
DocContentModelsByPageOrder.Add(doc);
|
||||
|
||||
if (doc.DocumentationModels.Count > 0) GetAllChildren(doc);
|
||||
}
|
||||
}
|
||||
|
||||
GetAllChildren(documentation);
|
||||
}
|
||||
|
||||
DocContentModelsByPageOrder = DocContentModelsByPageOrder.OrderBy(docContent => docContent.PageOrder).ToList();
|
||||
}
|
||||
|
||||
|
||||
private void AddTestCode()
|
||||
{
|
||||
DocContentModels.Add(new DocContentModel
|
||||
{
|
||||
Id = -110, Name = "Root Parent", Href = "root-parent", CreatedDate = DateTime.Now,
|
||||
UpdatedDate = DateTime.Now, Content = "Example root parent"
|
||||
});
|
||||
DocContentModels.Add(new DocContentModel
|
||||
{
|
||||
Id = -109, Name = "Child Parent", Href = "child-parent", CreatedDate = DateTime.Now,
|
||||
UpdatedDate = DateTime.Now, Content = "Example child parent"
|
||||
});
|
||||
DocContentModels.Add(new DocContentModel
|
||||
{
|
||||
Id = -108, Name = "Child Child 2", Href = "child-child", CreatedDate = DateTime.Now,
|
||||
UpdatedDate = DateTime.Now, Content = "Example child child"
|
||||
});
|
||||
DocContentModels.Add(new DocContentModel
|
||||
{
|
||||
Id = -107, Name = "A", Href = "A", CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, Content = "A"
|
||||
});
|
||||
DocContentModels.Add(new DocContentModel
|
||||
{
|
||||
Id = -106, Name = "B", Href = "B", CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, Content = "B"
|
||||
});
|
||||
|
||||
DocConnectionModels.Add(new DocConnectionModel { Id = -110, ParentId = -110, ChildId = -109 });
|
||||
DocConnectionModels.Add(new DocConnectionModel { Id = -109, ParentId = -109, ChildId = -108 });
|
||||
DocConnectionModels.Add(new DocConnectionModel { Id = -108, ParentId = -108, ChildId = -106 });
|
||||
DocConnectionModels.Add(new DocConnectionModel { Id = -107, ParentId = -108, ChildId = -107 });
|
||||
}
|
||||
|
||||
|
||||
private void NotifyDataChanged()
|
||||
{
|
||||
_onChange?.Invoke();
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Net.Http.Json;
|
||||
using Model.Work.Git;
|
||||
using Model.Development.Git;
|
||||
|
||||
#if NO_SQL
|
||||
|
||||
@@ -15,13 +15,16 @@ public class GitService : IGitService {
|
||||
|
||||
private bool isLoaded;
|
||||
|
||||
private event Action OnChange = default!;
|
||||
|
||||
|
||||
public GitService(HttpClient httpClient) {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
#if NO_SQL
|
||||
public List<ChangeModel> ChangeModels { get; set; }
|
||||
public List<PatchModel> PatchModels { get; set; }
|
||||
public List<GitChangeModel> GitChangeModels { get; set; } = default!;
|
||||
public List<GitPatchModel> GitPatchModels { get; set; } = default!;
|
||||
#else
|
||||
public DbSet<ChangeModel> ChangeModels => Database.ChangeModels;
|
||||
public DbSet<PatchModel> PatchModels => Database.PatchModels;
|
||||
@@ -31,11 +34,11 @@ public class GitService : IGitService {
|
||||
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange -= action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public bool IsLoaded() {
|
||||
@@ -51,8 +54,8 @@ public class GitService : IGitService {
|
||||
return;
|
||||
}
|
||||
|
||||
ChangeModels = (await httpClient.GetFromJsonAsync<ChangeModel[]>("generated/ChangeModels.json") ?? Array.Empty<ChangeModel>()).ToList();
|
||||
PatchModels = (await httpClient.GetFromJsonAsync<PatchModel[]>("generated/PatchModels.json") ?? Array.Empty<PatchModel>()).ToList();
|
||||
GitChangeModels = (await httpClient.GetFromJsonAsync<GitChangeModel[]>("generated/GitChangeModels.json") ?? Array.Empty<GitChangeModel>()).ToList();
|
||||
GitPatchModels = (await httpClient.GetFromJsonAsync<GitPatchModel[]>("generated/GitPatchModels.json") ?? Array.Empty<GitPatchModel>()).ToList();
|
||||
|
||||
|
||||
isLoaded = true;
|
||||
@@ -69,8 +72,8 @@ public class GitService : IGitService {
|
||||
return;
|
||||
}
|
||||
|
||||
Database.ChangeModels.AddRange(await httpClient.GetFromJsonAsync<ChangeModel[]>("generated/ChangeModels.json"));
|
||||
Database.PatchModels.AddRange(await httpClient.GetFromJsonAsync<PatchModel[]>("generated/PatchModels.json"));
|
||||
Database.ChangeModels.AddRange(await httpClient.GetFromJsonAsync<ChangeModel[]>("generated/GitChangeModels.json"));
|
||||
Database.PatchModels.AddRange(await httpClient.GetFromJsonAsync<PatchModel[]>("generated/GitPatchModels.json"));
|
||||
Database.SaveChanges();
|
||||
|
||||
|
||||
@@ -86,9 +89,7 @@ public class GitService : IGitService {
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
private event Action _onChange;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Net.Http.Json;
|
||||
using Model.Immortal.Notes;
|
||||
using Model.Notes;
|
||||
|
||||
#if NO_SQL
|
||||
|
||||
@@ -16,50 +16,115 @@ public class NoteService : INoteService {
|
||||
private bool isLoaded;
|
||||
|
||||
|
||||
private event Action _onChange;
|
||||
private event Action OnChange = default!;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
|
||||
public NoteService(HttpClient httpClient) {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
public List<NoteModel> NoteModels { get; set; }
|
||||
public List<NoteContentModel> NoteContentModels { get; set; } = default!;
|
||||
public List<NoteConnectionModel> NoteConnectionModels { get; set; }
|
||||
public List<NoteSectionModel> NoteSectionModels { get; set; }
|
||||
|
||||
public List<NoteContentModel> NoteContentModelsByPageOrder { get; set; } = new();
|
||||
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange -= action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public bool IsLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task Load() {
|
||||
|
||||
if (isLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
NoteModels = (await httpClient.GetFromJsonAsync<NoteModel[]>("generated/NoteModels.json") ?? Array.Empty<NoteModel>()).ToList();
|
||||
NoteContentModels = (await httpClient.GetFromJsonAsync<NoteContentModel[]>("generated/NoteContentModels.json") ?? Array.Empty<NoteContentModel>()).ToList();
|
||||
NoteConnectionModels = (await httpClient.GetFromJsonAsync<NoteConnectionModel[]>("generated/NoteConnectionModels.json") ?? Array.Empty<NoteConnectionModel>()).ToList();
|
||||
NoteSectionModels = (await httpClient.GetFromJsonAsync<NoteSectionModel[]>("generated/NoteSectionModels.json") ?? Array.Empty<NoteSectionModel>()).ToList();
|
||||
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
SortSQL();
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
private NoteContentModel? ContentById(int id)
|
||||
{
|
||||
foreach (var data in NoteContentModels!)
|
||||
if (data.Id == id)
|
||||
return data;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void SortSQL()
|
||||
{
|
||||
foreach (var connection in NoteConnectionModels)
|
||||
{
|
||||
ContentById(connection.ParentId)!.NoteContentModels.Add(ContentById(connection.ChildId));
|
||||
ContentById(connection.ChildId)!.Parent = ContentById(connection.ParentId);
|
||||
}
|
||||
|
||||
foreach (var content in NoteContentModels)
|
||||
{
|
||||
if (content.NoteSectionModelId != null)
|
||||
{
|
||||
foreach (var section in NoteSectionModels)
|
||||
{
|
||||
if (section.Id == content.NoteSectionModelId)
|
||||
{
|
||||
section.NoteContentModels.Add(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ByPageOrder();
|
||||
}
|
||||
|
||||
private void ByPageOrder()
|
||||
{
|
||||
NoteContentModelsByPageOrder = new List<NoteContentModel>();
|
||||
|
||||
int order = 1;
|
||||
foreach (var note in NoteContentModels)
|
||||
{
|
||||
if (note.Parent != null) continue;
|
||||
|
||||
note.PageOrder = order++;
|
||||
NoteContentModelsByPageOrder.Add(note);
|
||||
|
||||
void GetAllChildren(NoteContentModel docs)
|
||||
{
|
||||
foreach (var doc in docs.NoteContentModels)
|
||||
{
|
||||
doc.PageOrder = order++;
|
||||
NoteContentModelsByPageOrder.Add(doc);
|
||||
|
||||
if (doc.NoteContentModels.Count > 0) GetAllChildren(doc);
|
||||
}
|
||||
}
|
||||
|
||||
GetAllChildren(note);
|
||||
}
|
||||
|
||||
NoteContentModelsByPageOrder = NoteContentModelsByPageOrder.OrderBy(noteContent => noteContent.PageOrder).ToList();
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
+32
-25
@@ -5,16 +5,16 @@
|
||||
using Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
#endif
|
||||
using Model.Documentation;
|
||||
using Model.Immortal.BuildOrders;
|
||||
using Model.Immortal.Economy;
|
||||
using Model.Immortal.Entity;
|
||||
using Model.Immortal.Entity.Data;
|
||||
using Model.Immortal.MemoryTester;
|
||||
using Model.Immortal.Notes;
|
||||
using Model.Doc;
|
||||
using Model.BuildOrders;
|
||||
using Model.Economy;
|
||||
using Model.Entity;
|
||||
using Model.Entity.Data;
|
||||
using Model.MemoryTester;
|
||||
using Model.Notes;
|
||||
using Model.Website;
|
||||
using Model.Website.Enums;
|
||||
using Model.Work.Git;
|
||||
using Model.Development.Git;
|
||||
using Model.Work.Tasks;
|
||||
using Services.Immortal;
|
||||
|
||||
@@ -65,15 +65,15 @@ public interface IWebsiteService {
|
||||
public interface IAgileService {
|
||||
|
||||
#if NO_SQL
|
||||
public List<SprintModel> SprintModels { get; set; }
|
||||
public List<TaskModel> TaskModels { get; set; }
|
||||
public List<AgileSprintModel>? AgileSprintModels { get; set; }
|
||||
public List<AgileTaskModel>? AgileTaskModels { get; set; }
|
||||
#else
|
||||
public DbSet<SprintModel> SprintModels { get; }
|
||||
public DbSet<TaskModel> TaskModels { get; }
|
||||
#endif
|
||||
|
||||
public void Subscribe(Action action);
|
||||
public void Unsubscribe(Action action);
|
||||
public void Subscribe(Action? action);
|
||||
public void Unsubscribe(Action? action);
|
||||
public void Update();
|
||||
|
||||
#if NO_SQL
|
||||
@@ -85,7 +85,9 @@ public interface IAgileService {
|
||||
}
|
||||
|
||||
public interface INoteService {
|
||||
public List<NoteModel> NoteModels { get; set; }
|
||||
public List<NoteContentModel> NoteContentModels { get; set; }
|
||||
public List<NoteConnectionModel> NoteConnectionModels { get; set; }
|
||||
public List<NoteSectionModel> NoteSectionModels { get; set; }
|
||||
public void Subscribe(Action action);
|
||||
public void Unsubscribe(Action action);
|
||||
public void Update();
|
||||
@@ -93,10 +95,15 @@ public interface INoteService {
|
||||
public bool IsLoaded();
|
||||
}
|
||||
|
||||
public interface IDocumentationService {
|
||||
public List<DocumentationModel> DocumentationModels { get; set; }
|
||||
public void Subscribe(Action action);
|
||||
public void Unsubscribe(Action action);
|
||||
public interface IDocumentationService
|
||||
{
|
||||
public List<DocContentModel> DocContentModels { get; set; }
|
||||
public List<DocConnectionModel> DocConnectionModels { get; set; }
|
||||
public List<DocContentModel> DocContentModelsByPageOrder { get; set; }
|
||||
public List<DocSectionModel> DocSectionModels { get; set; }
|
||||
|
||||
public void Subscribe(Action? action);
|
||||
public void Unsubscribe(Action? action);
|
||||
public void Update();
|
||||
public Task Load();
|
||||
public bool IsLoaded();
|
||||
@@ -106,8 +113,8 @@ public interface IDocumentationService {
|
||||
public interface IGitService {
|
||||
|
||||
#if NO_SQL
|
||||
public List<ChangeModel> ChangeModels { get; set; }
|
||||
public List<PatchModel> PatchModels { get; set; }
|
||||
public List<GitChangeModel> GitChangeModels { get; set; }
|
||||
public List<GitPatchModel> GitPatchModels { get; set; }
|
||||
#else
|
||||
public DbSet<ChangeModel> ChangeModels { get; }
|
||||
public DbSet<PatchModel> PatchModels { get; }
|
||||
@@ -143,7 +150,7 @@ public interface INavigationService {
|
||||
}
|
||||
|
||||
public interface IBuildComparisonService {
|
||||
public void SetBuilds(BuildComparisonModel buildComparison);
|
||||
public void SetBuilds(BuildComparisonModel buildComparisonModel);
|
||||
public BuildComparisonModel Get();
|
||||
public string BuildOrderAsYaml();
|
||||
public string AsJson();
|
||||
@@ -155,8 +162,8 @@ public interface IBuildComparisonService {
|
||||
public interface ITimingService {
|
||||
public int GetTiming();
|
||||
public void SetTiming(int timing);
|
||||
public void Subscribe(Action action);
|
||||
public void Unsubscribe(Action action);
|
||||
public void Subscribe(Action? action);
|
||||
public void Unsubscribe(Action? action);
|
||||
}
|
||||
|
||||
public interface IEconomyService {
|
||||
@@ -218,13 +225,13 @@ public interface IImmortalSelectionService {
|
||||
|
||||
public interface IKeyService {
|
||||
public List<string> GetAllPressedKeys();
|
||||
public string GetHotkey();
|
||||
public string? GetHotkey();
|
||||
public string GetHotkeyGroup();
|
||||
public bool IsHoldingSpace();
|
||||
public bool AddPressedKey(string key);
|
||||
public bool RemovePressedKey(string key);
|
||||
public void Subscribe(Action action);
|
||||
public void Unsubscribe(Action action);
|
||||
public void Subscribe(Action? action);
|
||||
public void Unsubscribe(Action? action);
|
||||
}
|
||||
|
||||
public interface IMemoryTesterService {
|
||||
|
||||
@@ -1,50 +1,32 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Model.Immortal.BuildOrders;
|
||||
using Model.Immortal.Entity;
|
||||
using Model.Immortal.Entity.Data;
|
||||
using Model.BuildOrders;
|
||||
using Model.Entity;
|
||||
using Model.Entity.Data;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace Services.Immortal;
|
||||
|
||||
public class BuildComparisionService : IBuildComparisonService {
|
||||
private BuildComparisonModel buildComparison = new() {
|
||||
Builds = new List<BuildOrderModel> {
|
||||
new() {
|
||||
Name = "one base",
|
||||
Orders = new Dictionary<int, List<EntityModel>> {
|
||||
{
|
||||
0, new List<EntityModel> {
|
||||
new(DataType.STARTING_Bastion, EntityType.Building)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
new() {
|
||||
Name = "two base",
|
||||
Orders = new Dictionary<int, List<EntityModel>> {
|
||||
{
|
||||
0, new List<EntityModel> {
|
||||
new(DataType.STARTING_Bastion, EntityType.Building),
|
||||
new(DataType.STARTING_Bastion, EntityType.Building)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
private event Action OnChange = default!;
|
||||
|
||||
private BuildComparisonModel buildComparison = new();
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
onChange -= action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public void SetBuilds(BuildComparisonModel buildComparison) {
|
||||
this.buildComparison = buildComparison;
|
||||
private void NotifyDataChanged() {
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
|
||||
public void SetBuilds(BuildComparisonModel buildComparisonModel) {
|
||||
buildComparison = buildComparisonModel;
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
@@ -66,7 +48,7 @@ public class BuildComparisionService : IBuildComparisonService {
|
||||
WriteIndented = true
|
||||
};
|
||||
options.Converters.Add(new JsonStringEnumConverter());
|
||||
buildComparison = JsonSerializer.Deserialize<BuildComparisonModel>(data, options);
|
||||
buildComparison = JsonSerializer.Deserialize<BuildComparisonModel>(data, options)!;
|
||||
|
||||
// Must Hydrate because not loaded with Parts
|
||||
HydratedLoadedJson();
|
||||
@@ -87,15 +69,6 @@ public class BuildComparisionService : IBuildComparisonService {
|
||||
return buildOrderText;
|
||||
}
|
||||
|
||||
private event Action onChange;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
onChange?.Invoke();
|
||||
}
|
||||
|
||||
public Action OnChange() {
|
||||
return onChange;
|
||||
}
|
||||
|
||||
public void HydratedLoadedJson() {
|
||||
foreach (var build in buildComparison.Builds)
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Model.Immortal.BuildOrders;
|
||||
using Model.Immortal.Entity;
|
||||
using Model.Immortal.Types;
|
||||
using Model.BuildOrders;
|
||||
using Model.Entity;
|
||||
using Model.Types;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace Services.Immortal;
|
||||
|
||||
public class BuildOrderService : IBuildOrderService {
|
||||
public static int HumanMicro = 2;
|
||||
private int HumanMicro = 2;
|
||||
|
||||
private readonly BuildOrderModel buildOrder = new();
|
||||
private int lastInterval;
|
||||
|
||||
private int lastInterval = 0;
|
||||
|
||||
public int GetLastRequestInterval() {
|
||||
return lastInterval;
|
||||
}
|
||||
@@ -23,11 +23,11 @@ public class BuildOrderService : IBuildOrderService {
|
||||
}
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
onChange -= action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public void Add(EntityModel entity, int atInterval) {
|
||||
@@ -81,7 +81,7 @@ public class BuildOrderService : IBuildOrderService {
|
||||
}
|
||||
|
||||
public void RemoveLast() {
|
||||
EntityModel entityRemoved = null;
|
||||
EntityModel entityRemoved = null!;
|
||||
|
||||
|
||||
if (buildOrder.Orders.Keys.Count > 1) {
|
||||
@@ -184,7 +184,7 @@ public class BuildOrderService : IBuildOrderService {
|
||||
select requiredEntity;
|
||||
|
||||
|
||||
if (entitiesNeeded.Count() == 0) return false;
|
||||
if (!entitiesNeeded.Any()) return false;
|
||||
|
||||
|
||||
if (entitiesNeeded.Any() == false)
|
||||
@@ -212,8 +212,8 @@ public class BuildOrderService : IBuildOrderService {
|
||||
return buildOrder.Notes;
|
||||
}
|
||||
|
||||
public void SetColor(string Color) {
|
||||
buildOrder.Color = Color;
|
||||
public void SetColor(string color) {
|
||||
buildOrder.Color = color;
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
@@ -221,14 +221,10 @@ public class BuildOrderService : IBuildOrderService {
|
||||
return buildOrder.Color;
|
||||
}
|
||||
|
||||
private event Action onChange;
|
||||
private event Action OnChange = null!;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
onChange?.Invoke();
|
||||
}
|
||||
|
||||
public Action OnChange() {
|
||||
return onChange;
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
|
||||
public bool MeetsSupply(EntityModel entity) {
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
using Model.Immortal.Economy;
|
||||
using Model.Immortal.Entity;
|
||||
using Model.Immortal.Types;
|
||||
using Model.Economy;
|
||||
using Model.Entity;
|
||||
using Model.Types;
|
||||
|
||||
namespace Services.Immortal;
|
||||
|
||||
public class EconomyService : IEconomyService {
|
||||
private List<EconomyModel> _overTime;
|
||||
private List<EconomyModel> _overTime = null!;
|
||||
|
||||
public List<EconomyModel> GetOverTime() {
|
||||
return _overTime;
|
||||
}
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
onChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange -= action;
|
||||
onChange -= action;
|
||||
}
|
||||
|
||||
public void Calculate(IBuildOrderService buildOrder, ITimingService timing, int fromInterval) {
|
||||
@@ -137,13 +137,13 @@ public class EconomyService : IEconomyService {
|
||||
return _overTime[atInterval];
|
||||
}
|
||||
|
||||
private event Action _onChange;
|
||||
private event Action onChange = null!;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
onChange?.Invoke();
|
||||
}
|
||||
|
||||
public Action OnChange() {
|
||||
return _onChange;
|
||||
return onChange;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
using Model.Immortal.Types;
|
||||
using Model.Types;
|
||||
|
||||
namespace Services.Immortal;
|
||||
|
||||
public class EntityDisplayService : IEntityDisplayService {
|
||||
private string displayType = "Detailed";
|
||||
private event Action _onChange;
|
||||
private event Action OnChange = null!;
|
||||
|
||||
public List<string> DefaultChoices()
|
||||
{
|
||||
@@ -12,19 +12,15 @@ public class EntityDisplayService : IEntityDisplayService {
|
||||
}
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange -= action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
}
|
||||
|
||||
public Action OnChange() {
|
||||
return _onChange;
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
|
||||
public string GetDisplayType()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Model.Immortal.Entity.Data;
|
||||
using Model.Immortal.Types;
|
||||
using Model.Entity.Data;
|
||||
using Model.Types;
|
||||
using static Services.IEntityFilterService;
|
||||
|
||||
namespace Services.Immortal;
|
||||
@@ -159,7 +159,7 @@ public class EntityFilterService : IEntityFilterService {
|
||||
}
|
||||
|
||||
|
||||
private event EntityFilterAction _onChange;
|
||||
private event EntityFilterAction _onChange = null!;
|
||||
|
||||
private void NotifyDataChanged(EntityFilterEvent entityFilterEvent) {
|
||||
_onChange?.Invoke(entityFilterEvent);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Model.Immortal.Entity;
|
||||
using Model.Entity;
|
||||
|
||||
namespace Services.Immortal;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Model.Immortal.Types;
|
||||
using Model.Types;
|
||||
|
||||
namespace Services.Immortal;
|
||||
|
||||
@@ -7,11 +7,11 @@ public class ImmortalSelectionService : IImmortalSelectionService {
|
||||
private string _selectedImmortal = ImmortalType.Orzum;
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange -= action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public string GetFactionType() {
|
||||
@@ -41,13 +41,10 @@ public class ImmortalSelectionService : IImmortalSelectionService {
|
||||
return true;
|
||||
}
|
||||
|
||||
private event Action _onChange;
|
||||
private event Action OnChange = null!;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
|
||||
public Action OnChange() {
|
||||
return _onChange;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
using Model.Immortal.Hotkeys;
|
||||
using Model.Hotkeys;
|
||||
|
||||
namespace Services.Immortal;
|
||||
|
||||
public class KeyService : IKeyService {
|
||||
private static readonly List<string> _pressedKeys = new();
|
||||
private static readonly List<string> PressedKeys = new();
|
||||
private string? _hotkey;
|
||||
private string _hotkeyGroup = "C";
|
||||
private bool _isHoldingSpace;
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
public void Subscribe(Action? action) {
|
||||
_onChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
public void Unsubscribe(Action? action) {
|
||||
_onChange -= action;
|
||||
}
|
||||
|
||||
public bool AddPressedKey(string key) {
|
||||
_hotkey = null;
|
||||
|
||||
if (_pressedKeys.Count > 0) return false;
|
||||
if (PressedKeys.Count > 0) return false;
|
||||
var pressedKey = key.ToUpper();
|
||||
|
||||
if (pressedKey.Equals(" ") || pressedKey.Equals("SPACE")) {
|
||||
@@ -31,12 +31,12 @@ public class KeyService : IKeyService {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_pressedKeys.Contains(pressedKey)) {
|
||||
if (!PressedKeys.Contains(pressedKey)) {
|
||||
if (HotkeyModel.KeyGroups.Contains(pressedKey)) _hotkeyGroup = pressedKey;
|
||||
|
||||
if (HotkeyModel.HotKeys.Contains(pressedKey)) _hotkey = pressedKey;
|
||||
|
||||
_pressedKeys.Add(pressedKey);
|
||||
PressedKeys.Add(pressedKey);
|
||||
NotifyDataChanged();
|
||||
return true;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class KeyService : IKeyService {
|
||||
}
|
||||
|
||||
public List<string> GetAllPressedKeys() {
|
||||
return _pressedKeys;
|
||||
return PressedKeys;
|
||||
}
|
||||
|
||||
public bool RemovePressedKey(string key) {
|
||||
@@ -61,8 +61,8 @@ public class KeyService : IKeyService {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_pressedKeys.Contains(pressedKey)) {
|
||||
_pressedKeys.Remove(pressedKey);
|
||||
if (PressedKeys.Contains(pressedKey)) {
|
||||
PressedKeys.Remove(pressedKey);
|
||||
NotifyDataChanged();
|
||||
return true;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class KeyService : IKeyService {
|
||||
return _isHoldingSpace;
|
||||
}
|
||||
|
||||
public string GetHotkey() {
|
||||
public string? GetHotkey() {
|
||||
return _hotkey;
|
||||
}
|
||||
|
||||
@@ -82,13 +82,13 @@ public class KeyService : IKeyService {
|
||||
return _hotkeyGroup;
|
||||
}
|
||||
|
||||
private event Action _onChange;
|
||||
private event Action? _onChange;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
}
|
||||
|
||||
public Action OnChange() {
|
||||
public Action? OnChange() {
|
||||
return _onChange;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Model.Immortal.Entity;
|
||||
using Model.Immortal.Entity.Data;
|
||||
using Model.Immortal.MemoryTester;
|
||||
using Model.Entity;
|
||||
using Model.Entity.Data;
|
||||
using Model.MemoryTester;
|
||||
using static Services.IMemoryTesterService;
|
||||
|
||||
namespace Services.Immortal;
|
||||
@@ -18,11 +18,11 @@ public class MemoryTesterService : IMemoryTesterService {
|
||||
private readonly Random random = new();
|
||||
|
||||
public void Subscribe(MemoryAction action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(MemoryAction action) {
|
||||
_onChange -= action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public void GenerateQuiz() {
|
||||
@@ -88,13 +88,10 @@ public class MemoryTesterService : IMemoryTesterService {
|
||||
|
||||
//public delegate void MemoryAction(MemoryTesterActions memoryAction);
|
||||
|
||||
private event MemoryAction _onChange;
|
||||
private event MemoryAction OnChange = null!;
|
||||
|
||||
private void NotifyDataChanged(MemoryTesterEvent memoryAction) {
|
||||
_onChange?.Invoke(memoryAction);
|
||||
OnChange?.Invoke(memoryAction);
|
||||
}
|
||||
|
||||
public MemoryAction OnChange() {
|
||||
return _onChange;
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@
|
||||
public class TimingService : ITimingService {
|
||||
private int _timing = 360;
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
public void Subscribe(Action? action) {
|
||||
_onChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
public void Unsubscribe(Action? action) {
|
||||
_onChange -= action;
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ public class TimingService : ITimingService {
|
||||
}
|
||||
}
|
||||
|
||||
private event Action _onChange;
|
||||
private event Action? _onChange;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
}
|
||||
|
||||
public Action OnChange() {
|
||||
public Action? OnChange() {
|
||||
return _onChange;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DataType = Model.Immortal.Entity.Data.DataType;
|
||||
using DataType = Model.Entity.Data.DataType;
|
||||
|
||||
namespace Services.Website;
|
||||
|
||||
@@ -10,18 +10,18 @@ public class EntityDialogService : IEntityDialogService
|
||||
|
||||
private List<string> history = new List<string>();
|
||||
|
||||
private event Action _onChange;
|
||||
private event Action OnChange = null!;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void AddDialog(string id)
|
||||
|
||||
@@ -7,16 +7,16 @@ public class NavigationService : INavigationService {
|
||||
|
||||
private NavSelectionType navSelectionType = NavSelectionType.None;
|
||||
|
||||
private Type renderType;
|
||||
private Type renderType = null!;
|
||||
private int webPageType;
|
||||
private int webSectionType;
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void ChangeNavigationState(string newState) {
|
||||
@@ -83,13 +83,9 @@ public class NavigationService : INavigationService {
|
||||
return renderType;
|
||||
}
|
||||
|
||||
private event Action _onChange;
|
||||
private event Action OnChange = null!;
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
}
|
||||
|
||||
public Action OnChange() {
|
||||
return _onChange;
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class WebsiteService : IWebsiteService {
|
||||
private bool isLoaded;
|
||||
|
||||
|
||||
private event Action _onChange;
|
||||
private event Action OnChange = default!;
|
||||
|
||||
|
||||
public WebsiteService(HttpClient httpClient) {
|
||||
@@ -25,8 +25,8 @@ public class WebsiteService : IWebsiteService {
|
||||
|
||||
|
||||
#if NO_SQL
|
||||
public List<WebSectionModel> WebSectionModels { get; set; }
|
||||
public List<WebPageModel> WebPageModels { get; set; }
|
||||
public List<WebSectionModel> WebSectionModels { get; set; } = default!;
|
||||
public List<WebPageModel> WebPageModels { get; set; } = default!;
|
||||
#else
|
||||
|
||||
private DatabaseContext Database { get; set; }
|
||||
@@ -38,11 +38,11 @@ public class WebsiteService : IWebsiteService {
|
||||
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
_onChange -= action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public bool IsLoaded() {
|
||||
@@ -54,8 +54,10 @@ public class WebsiteService : IWebsiteService {
|
||||
public async Task Load() {
|
||||
if (isLoaded) {return;}
|
||||
|
||||
WebPageModels = (await httpClient.GetFromJsonAsync<WebPageModel[]>("generated/WebPageModels.json")).ToList();
|
||||
WebSectionModels =(await httpClient.GetFromJsonAsync<WebSectionModel[]>("generated/WebSectionModels.json")).ToList();
|
||||
|
||||
|
||||
WebPageModels = ((await httpClient.GetFromJsonAsync<WebPageModel[]>("generated/WebPageModels.json"))!).ToList();
|
||||
WebSectionModels =((await httpClient.GetFromJsonAsync<WebSectionModel[]>("generated/WebSectionModels.json"))!).ToList();
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
@@ -85,6 +87,6 @@ public class WebsiteService : IWebsiteService {
|
||||
}
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
_onChange?.Invoke();
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user