diff --git a/IISExpressGui/IISExpressGui.IISManagement/Interfaces/IWebSiteManager.cs b/IISExpressGui/IISExpressGui.IISManagement/Interfaces/IWebSiteManager.cs index 59f09cb..a5e2209 100644 --- a/IISExpressGui/IISExpressGui.IISManagement/Interfaces/IWebSiteManager.cs +++ b/IISExpressGui/IISExpressGui.IISManagement/Interfaces/IWebSiteManager.cs @@ -15,5 +15,7 @@ public interface IWebSiteManager void Update(WebSite webSite); void ToggleStatus(WebSite webSite); + + void Remove(long webSiteId); } } diff --git a/IISExpressGui/IISExpressGui.IISManagement/WebSiteManager.cs b/IISExpressGui/IISExpressGui.IISManagement/WebSiteManager.cs index f8a122a..f4b3e95 100644 --- a/IISExpressGui/IISExpressGui.IISManagement/WebSiteManager.cs +++ b/IISExpressGui/IISExpressGui.IISManagement/WebSiteManager.cs @@ -18,7 +18,7 @@ public class WebSiteManager : IWebSiteManager string applicationHostConfigPath; XmlDocument applicationHostConfig = new XmlDocument(); - Dictionary runningProcesses = new Dictionary(); + Dictionary runningProcesses = new Dictionary(); #endregion @@ -40,13 +40,13 @@ public WebSiteManager(string applicationHostConfigPath) public string IISPath { get { return IISExpress.IISDefaultPath; } - } + } #endregion - + #region Public Methods - public IList GetAllWebSites() + public IList GetAllWebSites() { if (!ApplicationHostConfigExists()) { @@ -160,7 +160,8 @@ public void Update(WebSite webSite) var virtualDirectoryNode = siteNode.SelectSingleNode("descendant::virtualDirectory"); virtualDirectoryNode.Attributes["physicalPath"].Value = webSite.PhysicalPath; var bindingNode = siteNode.SelectSingleNode("descendant::binding"); - bindingNode.Attributes["bindingInformation"].Value = string.Format(":{0}:localhost", webSite.Port); + var ip = webSite.Url.Replace("http://", ""); + bindingNode.Attributes["bindingInformation"].Value = string.Format(":{0}:{1}", webSite.Port, ip); this.applicationHostConfig.Save(this.applicationHostConfigPath); } @@ -181,6 +182,15 @@ public void ToggleStatus(WebSite webSite) } } + public void Remove(long webSiteId) + { + var siteByIdQuery = string.Format("descendant::site[@id='{0}']", webSiteId); + var siteNode = this.applicationHostConfig.SelectSingleNode(siteByIdQuery); + if (siteNode == null) return; + siteNode.ParentNode?.RemoveChild(siteNode); + this.applicationHostConfig.Save(this.applicationHostConfigPath); + } + public bool IsIISExpressInstalled() { return File.Exists(IISPath); @@ -191,7 +201,7 @@ public bool ApplicationHostConfigExists() return File.Exists(applicationHostConfigPath); } - #endregion + #endregion #region Private Methods @@ -209,7 +219,7 @@ private void Stop(WebSite webSite) this.runningProcesses.Remove(webSite.Id); iisExpressInstance.Stop(); } - } + } #endregion } diff --git a/IISExpressGui/IISExpressGui.Presentation/MainWindow.xaml b/IISExpressGui/IISExpressGui.Presentation/MainWindow.xaml index 47f32c2..cad424d 100644 --- a/IISExpressGui/IISExpressGui.Presentation/MainWindow.xaml +++ b/IISExpressGui/IISExpressGui.Presentation/MainWindow.xaml @@ -8,12 +8,13 @@ - + + diff --git a/IISExpressGui/IISExpressGui.Presentation/MainWindowResources.xaml b/IISExpressGui/IISExpressGui.Presentation/MainWindowResources.xaml index 4dcd6cc..fc9b3c8 100644 --- a/IISExpressGui/IISExpressGui.Presentation/MainWindowResources.xaml +++ b/IISExpressGui/IISExpressGui.Presentation/MainWindowResources.xaml @@ -114,6 +114,8 @@ HeaderTemplate="{StaticResource ContextMenuItemHeaderTemplate}" Command="{Binding Path=ToggleStatusCommand}" /> + @@ -165,6 +167,7 @@ + @@ -187,8 +190,8 @@ HorizontalAlignment="Right" Target="portTextBox"/> - + -