add support for REST-ful API building

- allow parameters within url
- allow different methods other then just POST
-> still needs to be tested!
This commit is contained in:
Pilzinsel64
2024-11-28 09:03:48 +01:00
parent 74ebbbca7b
commit 9dcaa7e507
9 changed files with 239 additions and 53 deletions

View File

@@ -0,0 +1,10 @@
namespace Pilz.UI.Controls.ConfigurationManager;
public class ConfigurationEntry(string name, string title, ConfigurationValueListener Listener)
{
public event EventHandler? OnValueChanged;
public string Name { get; } = name;
public string Title { get; } = title;
public ConfigurationValueListener Listener { get; } = Listener;
}

View File

@@ -0,0 +1,20 @@
namespace Pilz.UI.Controls.ConfigurationManager;
public class ConfigurationManager
{
private readonly List<ConfigurationPanel> panels = [];
public void Register(ConfigurationPanel panel)
{
panels.Add(panel);
}
public IEnumerable<Control> Build()
{
foreach (var panel in panels)
{
panel.Build(this);
yield return panel;
}
}
}

View File

@@ -0,0 +1,32 @@
namespace Pilz.UI.Controls.ConfigurationManager;
public class ConfigurationPanel : TableLayoutPanel
{
private readonly List<ConfigurationEntry> entries = [];
public ConfigurationEntry CreateEntry(string name, string title)
{
return CreateEntry(name, title, null);
}
public ConfigurationEntry CreateEntry(string name, string title, Action? create)
{
return CreateEntry(new(name, title, ));
}
public ConfigurationEntry CreateEntry(ConfigurationEntry entry)
{
entries.Add(entry);
return entry;
}
internal protected void Build(ConfigurationManager manager)
{
foreach (var entry in entries)
{
var control = ;
entry.Listener.Initialize();
// ...
}
}
}

View File

@@ -0,0 +1,15 @@
namespace Pilz.UI.Controls.ConfigurationManager;
public abstract class ConfigurationValueListener : IDisposable
{
public event EventHandler? ValueChanged;
protected virtual void OnValueChanged(object sender, EventArgs e)
{
ValueChanged?.Invoke(sender, e);
}
internal protected abstract void Initialize(Control control);
public abstract void Dispose();
}