using irisHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace irisMemory
{
    public class AppConfig
    {
        private int tempType;
        private int showTimeFailure;
        private int rejectTimeOut;
        private int showTimeSuccess;

        private int language;

        private DbServerConfig dbServerConfig;/*服务器链接配置*/
        private DbLocalConfig dbLocalConfig;
        private AuthConfig authConfig;
        
        private static AppConfig _appConfig = null;

        public int ShowTimeFailure
        {
            get
            {
                return showTimeFailure;
            }

            set
            {
                showTimeFailure = value;
            }
        }

        public DbServerConfig DbServerConfig
        {
            get
            {
                return dbServerConfig;
            }

            set
            {
                dbServerConfig = value;
            }
        }

        public DbLocalConfig DbLocalConfig
        {
            get
            {
                return dbLocalConfig;
            }

            set
            {
                dbLocalConfig = value;
            }
        }

        public AuthConfig AuthConfig
        {
            get
            {
                return authConfig;
            }

            set
            {
                authConfig = value;
            }
        }

        public int RejectTimeOut
        {
            get
            {
                return rejectTimeOut;
            }

            set
            {
                rejectTimeOut = value;
            }
        }

        public int ShowTimeSuccess
        {
            get
            {
                return showTimeSuccess;
            }

            set
            {
                showTimeSuccess = value;
            }
        }

        public int Language
        {
            get
            {
                return language;
            }

            set
            {
                language = value;
            }
        }

        public int TempType
        {
            get
            {
                return tempType;
            }

            set
            {
                tempType = value;
            }
        }

        private AppConfig()//私有构造函数，保证唯一性
        {
            ShowTimeFailure = Convert.ToInt32(ConfigHelper.GetAppConfig("showTimeFailure"));
            RejectTimeOut = Convert.ToInt32(ConfigHelper.GetAppConfig("rejectTimeOut"));
            ShowTimeSuccess = Convert.ToInt32(ConfigHelper.GetAppConfig("showTimeSuccess"));
            Language = Convert.ToInt32(ConfigHelper.GetAppConfig("language"));
            tempType = Convert.ToInt32(ConfigHelper.GetAppConfig("tempType"));

            DbServerConfig = new DbServerConfig().InitDbServerConfig();
            DbLocalConfig = new DbLocalConfig().InitDbLocalConfig();

            AuthConfig = new AuthConfig();
        }

        public static AppConfig GetInstance()
        {
            if (_appConfig == null)
                _appConfig = new AppConfig();

            return _appConfig;
        }

    }
}