44 lines
941 B
C#
44 lines
941 B
C#
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
|
|
using ServerCore;
|
|
|
|
|
|
|
|
using WORLD_META_ID = System.UInt32;
|
|
using CHANNEL_NO = System.UInt32;
|
|
|
|
|
|
namespace ServerCommon;
|
|
|
|
public static class ConfigHelper
|
|
{
|
|
public static WORLD_META_ID getWorldId(this IConfiguration config)
|
|
{
|
|
return uint.Parse(config["worldId"] ?? "0");
|
|
}
|
|
|
|
public static ushort getPort(this IConfiguration config)
|
|
{
|
|
return ushort.Parse(config["port"] ?? "0");
|
|
}
|
|
|
|
public static CHANNEL_NO getChannelNo(this IConfiguration config)
|
|
{
|
|
return uint.Parse(config["channelNo"] ?? "0");
|
|
}
|
|
|
|
public static ServerType getServerType(this IConfiguration config)
|
|
{
|
|
var value = config["config"];
|
|
|
|
if (Enum.TryParse<ServerType>(value, true, out var serverType))
|
|
{
|
|
return serverType;
|
|
}
|
|
|
|
throw new Exception($"Invalid or missing ServerType in IConfiguration:{value}");
|
|
}
|
|
}
|