public HttpServer(WebSiteConfig cfg, BaseLog log)
        {
            _Config = cfg;
            Logger  = log;

            _Config.PhysicalPath = _Config.PhysicalPath == null?
                                   Directory.GetCurrentDirectory() :
                                       ((_Config.PhysicalPath.EndsWith(@"\") ? _Config.PhysicalPath : _Config.PhysicalPath + @"\"));

            listener = new BuildInHttpListener(int.Parse(Config.Port));
            //listener = new SocketListener(int.Parse(Config.Port));

            //cache = new LocalFileCache(_Config.PhysicalPath);
            cache      = new RedisCache();
            urlHandler = new HandlerChain(_Config.SiteName, _Config.PhysicalPath, cache);
        }
        public static List <WebSiteConfig> GetAllSites()
        {
            List <WebSiteConfig> list = new List <WebSiteConfig>();

            using (StreamReader sr = new StreamReader(cfgPath, Encoding.UTF8))
            {
                do
                {
                    string r = sr.ReadLine();
                    if (r == null || r == "")
                    {
                        break;
                    }
                    var           strs = r.Split('@');
                    WebSiteConfig cfg  = new WebSiteConfig();
                    cfg.SiteName     = strs[0];
                    cfg.Port         = strs[1];
                    cfg.PhysicalPath = strs[2];
                    list.Add(cfg);
                } while (true);
            }
            return(list);
        }