Files
point_of_sale_v2/PointOfSale/Pos.Ui/Database/LoadConfig.cs
Bjarne Pedersen 170a03e7df Print problemer
Har muligvis rettet den print fejl der er - men mangler at få det testet.
Der er slettet en masse projekter som ikke bliver brugt mere.
Og flyttet rundt på de få projekter som er tilbage.
Dette er V2 og i sit eget repo, så dette er initial commit
2026-07-15 22:40:53 +02:00

61 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
namespace Pos
{
public class LoadConfig
{
private string dir;
public LoadConfig()
{
dir = AppDomain.CurrentDomain.BaseDirectory;
}
public IConfiguration ByEnvironment()
{
//Console.Out.WriteLine($"Json path: {dir}");
#if DEBUG
var config = new ConfigurationBuilder()
.SetBasePath(dir)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true)
.Build();
return config;
#else
var config = new ConfigurationBuilder()
.SetBasePath(dir)
.AddJsonFile("appsettings.Production.json", optional: true, reloadOnChange: true)
.Build();
return config;
#endif
//Running in a environment that not is supported in this setup
throw new Exception("HostingEnvironment is not supported! This config setup only supports Development or Production");
}
public IConfiguration DebugConfiguration()
{
var config = new ConfigurationBuilder()
.SetBasePath(dir)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true)
.Build();
return config;
}
public IConfiguration ReleaseConfiguration()
{
var config = new ConfigurationBuilder()
.SetBasePath(dir)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsettings.Production.json", optional: true, reloadOnChange: true)
.Build();
return config;
}
}
}