Skip to content

Commit

Permalink
chore: add configuration provider
Browse files Browse the repository at this point in the history
  • Loading branch information
DariuszGarbarz committed Aug 29, 2024
1 parent 3a910a8 commit 1fc04f7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions BleBoxCommonSimLib/ServiceExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using BleBoxCommonSimLib.Services;
using BleBoxModels.Common.Models;
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json.Nodes;

namespace BleBoxCommonSimLib;

Expand All @@ -14,4 +16,24 @@ public static IServiceCollection AddCommonSim(this IServiceCollection services)

return services;
}

public static IServiceProvider ConfigureCommonSim(
this IServiceProvider services,
string deviceName,
string type,
string apiLevel,
Func<SettingsBase, object> obtainFullSettings,
Func<JsonObject, SettingsBase> updateFullSettings,
string product = "commonBox")
{
var deviceService = services.GetRequiredService<IDeviceInformationService>();
deviceService.InitializeDevice(deviceName, type, apiLevel, product);

var settingsService = services.GetRequiredService<ISettingsService>();

settingsService.ObtainFullSettings = obtainFullSettings;
settingsService.UpdateFullSettings = updateFullSettings;

return services;
}
}

0 comments on commit 1fc04f7

Please sign in to comment.