49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using Microsoft.Extensions.Configuration;
|
|||
|
|
|
|||
|
|
namespace ViewModels.Common
|
|||
|
|
{
|
|||
|
|
public class ReadConfig
|
|||
|
|
{
|
|||
|
|
public static ReadConfig Instance = new ReadConfig();
|
|||
|
|
public IConfiguration? Configuration { get; set; }
|
|||
|
|
public string? MySQLConnectionString { get; set; }
|
|||
|
|
public string? get_monitor_filter { get; set; }
|
|||
|
|
public string? get_session_expire_minutes { get; set; }
|
|||
|
|
public string? get_redis_server_session { get; set; }
|
|||
|
|
public string? get_redis_max_read_pool { get; set; }
|
|||
|
|
public string? get_redis_max_write_pool { get; set; }
|
|||
|
|
|
|||
|
|
public string? MQTT_ServerIP { get; set; }
|
|||
|
|
public int? MQTT_ServerPort { get; set; }
|
|||
|
|
public string? MQTT_User { get; set; }
|
|||
|
|
public string? MQTT_PassWord { get; set; }
|
|||
|
|
|
|||
|
|
|
|||
|
|
public ReadConfig()
|
|||
|
|
{
|
|||
|
|
Configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("app.json").Build();
|
|||
|
|
MySQLConnectionString = Configuration.GetConnectionString("SQLServerConnectionString");
|
|||
|
|
|
|||
|
|
get_session_expire_minutes = Configuration.GetSection("session_expire_minutes").Value;
|
|||
|
|
get_redis_server_session = Configuration.GetSection("redis_server_session").Value;
|
|||
|
|
get_redis_max_read_pool = Configuration.GetSection("redis_max_read_pool").Value;
|
|||
|
|
get_redis_max_write_pool = Configuration.GetSection("redis_max_write_pool").Value;
|
|||
|
|
|
|||
|
|
|
|||
|
|
MQTT_ServerIP = Configuration.GetSection("MQTT_ServerIP").Value;
|
|||
|
|
|
|||
|
|
int p = 1883;
|
|||
|
|
int.TryParse(Configuration.GetSection("MQTT_ServerPort").Value, out p);
|
|||
|
|
MQTT_ServerPort = p;
|
|||
|
|
|
|||
|
|
MQTT_User = Configuration.GetSection("MQTT_User").Value;
|
|||
|
|
MQTT_PassWord = Configuration.GetSection("MQTT_PWD").Value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|