mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
* Introduce very flexible form input system * Refactorings after rebase * Test fix * Update BTCPayServer/Forms/FormDataService.cs --------- Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
using BTCPayServer.Data;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace BTCPayServer.Forms;
|
|
|
|
public static class FormDataExtensions
|
|
{
|
|
public static void AddForms(this IServiceCollection serviceCollection)
|
|
{
|
|
serviceCollection.AddSingleton<FormDataService>();
|
|
serviceCollection.AddSingleton<FormComponentProviders>();
|
|
serviceCollection.AddSingleton<IFormComponentProvider, HtmlInputFormProvider>();
|
|
serviceCollection.AddSingleton<IFormComponentProvider, HtmlFieldsetFormProvider>();
|
|
serviceCollection.AddSingleton<IFormComponentProvider, HtmlSelectFormProvider>();
|
|
serviceCollection.AddSingleton<IFormComponentProvider, FieldValueMirror>();
|
|
}
|
|
|
|
public static JObject Deserialize(this FormData form)
|
|
{
|
|
return JsonConvert.DeserializeObject<JObject>(form.Config);
|
|
}
|
|
|
|
public static string Serialize(this JObject form)
|
|
{
|
|
return JsonConvert.SerializeObject(form);
|
|
}
|
|
}
|