using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GWSocketClient.property
{
    class PropertiesLoader
    {
        public Dictionary<string, string> PROPERTIES = new Dictionary<string, string>();

        public PropertiesLoader()
        {
            string propertiesPath = @"";
            loadPropertiesFile(propertiesPath);
        }

        public PropertiesLoader(string propertiesPath)
        {
            loadPropertiesFile(propertiesPath);
        }

        public PropertiesLoader loadPropertiesFile(string propertiesPath)
        {
            StreamReader sr = new StreamReader(propertiesPath);
            string line = "";
            while ((line = sr.ReadLine()) != null)
            {
                if (line.Trim().Equals(""))
                    continue;

                int post = line.IndexOf("=");
                PROPERTIES.Add(line.Substring(0, post), line.Substring(post + 1));
            }

            sr.Close();
            return this;
        }
    }
}