/// <summary> /// Создает сервер на определенном порту /// </summary> /// <param name="port"></param> public HostServer(int port) { var cfg = new HostConfig(); cfg.AddDefaultBinding(); cfg.Bindings[0].Port = port; Config = cfg; }
private static HostConfig PrepareHostConfig(string[] args) { var cfg = new HostConfig(); cfg.ApplicationMode = HostApplicationMode.Standalone; var argdicts = new ConsoleArgumentHelper().ParseDictionary(args); if (argdicts.ContainsKey("config")) { var configFile = argdicts["config"]; XElement configXml = null; if (configFile.EndsWith(".xml")) { configXml = XElement.Load(configFile); } else { configXml = new BxlParser().Parse(File.ReadAllText(configFile), configFile); } cfg.LoadXmlConfig(configXml); } if (argdicts.ContainsKey("root")) { cfg.RootFolder = Path.GetFullPath(argdicts["root"]); } if (cfg.Bindings.Count == 0) { cfg.AddDefaultBinding(); } if (argdicts.ContainsKey("port")){ cfg.Bindings[0].Port = argdicts["port"].ToInt(); } if (argdicts.ContainsKey("content")){ var folders = argdicts["content"].SmartSplit(false, true, ';'); foreach (var folder in folders){ cfg.ContentFolders.Add(folder); } } if (argdicts.ContainsKey("appname")) { foreach (var hostBinding in cfg.Bindings) { if (hostBinding.AppName == "/") { hostBinding.AppName = argdicts["appname"]; } } } return cfg; }
/// <summary> /// Создает новый экземпляр сервера /// </summary> /// <param name="config"></param> public HostServer(HostConfig config) { Config = config; }