using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace SamaPager_Server
{
    internal class ConfigManager
    {
        internal string FileName = "config.json";
        internal string ListeningIP { get; set; }
        internal int ListeningPort { get; set; }

        internal ConfigManager(string fileName)
        {
            this.FileName = fileName;

            if (!File.Exists(FileName))
            {
                ListeningIP = "0.0.0.0";
                ListeningPort = 2000;
            }
            else
            {
                string rawJson = File.ReadAllText(FileName);
                ConfigManager config = JsonConvert.DeserializeObject<ConfigManager>(rawJson);
                ListeningIP = config.ListeningIP;
                ListeningPort = config.ListeningPort;
            }
        }
    }
}
