fix : 서버 설정파일 빼기 작업
This commit is contained in:
62
MMOTestServer/MMOserver/Config/AppConfig.cs
Normal file
62
MMOTestServer/MMOserver/Config/AppConfig.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace MMOserver.Config;
|
||||
|
||||
public static class AppConfig
|
||||
{
|
||||
public static ServerConfig Server
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = null!;
|
||||
|
||||
public static RestApiConfig RestApi
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = null!;
|
||||
|
||||
public static void Initialize(IConfiguration config)
|
||||
{
|
||||
Server = new ServerConfig(config.GetSection("Server"));
|
||||
RestApi = new RestApiConfig(config.GetSection("RestApi"));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ServerConfig
|
||||
{
|
||||
public int Port
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public ServerConfig(IConfigurationSection section)
|
||||
{
|
||||
Port = int.Parse(section["Port"] ?? throw new InvalidOperationException("Server:Port is required in config.json"));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RestApiConfig
|
||||
{
|
||||
public string BaseUrl
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public string VerifyToken
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public string ApiKey
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public RestApiConfig(IConfigurationSection section)
|
||||
{
|
||||
BaseUrl = section["BaseUrl"] ?? throw new InvalidOperationException("RestApi:BaseUrl is required in config.json");
|
||||
VerifyToken = section["VerifyToken"] ?? throw new InvalidOperationException("RestApi:BaseUrl is required in config.json");
|
||||
ApiKey = section["ApiKey"] ?? throw new InvalidOperationException("RestApi:ApiKey is required in config.json");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user