Пример #1
0
        private void AddHostPrefix(HostPrefix hp)
        {
            _listening.TryAdd(hp, this);
            string path = hp.ToString();

            _logger.AddEntry("HttpServer: {0}", path);
            _listener.Prefixes.Add(path);
        }
Пример #2
0
        public override bool Equals(object obj)
        {
            HostPrefix compareTo = obj as HostPrefix;

            if (compareTo != null)
            {
                return(compareTo.ToString().Equals(this.ToString()));
            }
            return(base.Equals(obj));
        }
Пример #3
0
        public static HostPrefix[] FromDefaultConfiguration(string defaultHostName = "localhost", int defaultPort = 80)
        {
            int  port = int.Parse(DefaultConfiguration.GetAppSetting("Port", defaultPort.ToString()));
            bool ssl  = DefaultConfiguration.GetAppSetting("Ssl").IsAffirmative();
            List <HostPrefix> results = new List <HostPrefix>();

            foreach (string hostName in DefaultConfiguration.GetAppSetting("HostNames").Or(defaultHostName).DelimitSplit(",", true))
            {
                HostPrefix hostPrefix = new HostPrefix()
                {
                    HostName = hostName,
                    Port     = port,
                    Ssl      = ssl
                };
                results.Add(hostPrefix);
                Trace.Write($"Default Config Hostname: {hostPrefix.ToString()}");
            }
            return(results.ToArray());
        }