12 changed files with 292 additions and 115 deletions
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.EnterpriseServices.Internal; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class IIS6Administrator : IISAdministrator |
||||
{ |
||||
const string IIS_WEB_LOCATION = "IIS://localhost/W3SVC/1/Root"; |
||||
|
||||
public IIS6Administrator(WebProjectProperties properties) |
||||
: base(properties) |
||||
{ |
||||
} |
||||
|
||||
public override bool IsIISInstalled() |
||||
{ |
||||
return WebProjectService.IsIISInstalled; |
||||
} |
||||
|
||||
public override void CreateVirtualDirectory(WebProject project) |
||||
{ |
||||
string error = null; |
||||
var virtualRoot = new IISVirtualRoot(); |
||||
virtualRoot.Create(IIS_WEB_LOCATION, |
||||
project.Directory, |
||||
project.Name, |
||||
out error); |
||||
if (!String.IsNullOrEmpty(error)) { |
||||
throw new ApplicationException(error); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class IIS7Administrator : IISAdministrator |
||||
{ |
||||
public IIS7Administrator(WebProjectProperties properties) |
||||
: base(properties) |
||||
{ |
||||
} |
||||
|
||||
public override bool IsIISInstalled() |
||||
{ |
||||
return WebProjectService.IsIISInstalled; |
||||
} |
||||
|
||||
public override void CreateVirtualDirectory(WebProject project) |
||||
{ |
||||
string name = "/" + project.Name; |
||||
|
||||
dynamic manager = CreateServerManager(); |
||||
|
||||
if (manager.Sites[DEFAULT_WEB_SITE] != null) { |
||||
if (manager.Sites[DEFAULT_WEB_SITE].Applications[name] == null) { |
||||
manager.Sites[DEFAULT_WEB_SITE].Applications.Add(name, project.Directory); |
||||
manager.CommitChanges(); |
||||
} else { |
||||
ThrowApplicationExistsException(); |
||||
} |
||||
} else { |
||||
if (manager.Sites[0].Applications[name] == null) { |
||||
manager.Sites[0].Applications.Add(name, project.Directory); |
||||
manager.CommitChanges(); |
||||
} else { |
||||
ThrowApplicationExistsException(); |
||||
} |
||||
} |
||||
manager.Dispose(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public abstract class IISAdministrator |
||||
{ |
||||
public const string DEFAULT_WEB_SITE = "Default Web Site"; |
||||
|
||||
protected IISAdministrator(WebProjectProperties properties) |
||||
{ |
||||
this.Properties = properties; |
||||
} |
||||
|
||||
protected IISAdministrator() |
||||
{ |
||||
} |
||||
|
||||
protected WebProjectProperties Properties { get; set; } |
||||
|
||||
public static IISAdministrator CreateAdministrator(WebProjectProperties properties) |
||||
{ |
||||
if (properties.UseIISExpress) { |
||||
return new IISExpressAdministrator(properties); |
||||
} |
||||
switch (WebProjectService.IISVersion) { |
||||
case IISVersion.IIS5: |
||||
case IISVersion.IIS6: |
||||
return new IIS6Administrator(properties); |
||||
case IISVersion.None: |
||||
return new NullIISAdministrator(); |
||||
default: |
||||
return new IIS7Administrator(properties); |
||||
} |
||||
} |
||||
|
||||
public abstract bool IsIISInstalled(); |
||||
|
||||
public abstract void CreateVirtualDirectory(WebProject project); |
||||
|
||||
protected dynamic CreateServerManager() |
||||
{ |
||||
Assembly webAdministrationAssembly = GetWebAdminstrationAssembly(); |
||||
return webAdministrationAssembly.CreateInstance("Microsoft.Web.Administration.ServerManager"); |
||||
} |
||||
|
||||
protected Assembly GetWebAdminstrationAssembly() |
||||
{ |
||||
foreach(DomAssemblyName assembly in GacInterop.GetAssemblyList()) { |
||||
if (assembly.FullName.Contains("Microsoft.Web.Administration")) { |
||||
if (IsServerManagementVersionRequired(assembly)) { |
||||
return Assembly.Load(assembly.FullName); |
||||
} |
||||
} |
||||
} |
||||
throw new ApplicationException(ResourceService.GetString("ICSharpCode.WebProjectOptionsPanel.IISNotFound")); |
||||
} |
||||
|
||||
|
||||
protected virtual bool IsServerManagementVersionRequired(DomAssemblyName assemblyName) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
protected void ThrowApplicationExistsException() |
||||
{ |
||||
throw new ApplicationException(ResourceService.GetString("ICSharpCode.WebProjectOptionsPanel.ApplicationExists")); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class IISExpressAdministrator : IISAdministrator |
||||
{ |
||||
public IISExpressAdministrator(WebProjectProperties properties) |
||||
: base(properties) |
||||
{ |
||||
} |
||||
|
||||
public override bool IsIISInstalled() |
||||
{ |
||||
return WebProjectService.IsIISExpressInstalled; |
||||
} |
||||
|
||||
public override void CreateVirtualDirectory(WebProject project) |
||||
{ |
||||
dynamic manager = CreateServerManager(); |
||||
dynamic site = manager.Sites.Add(project.Name, project.Directory, Properties.DevelopmentServerPort); |
||||
string bindingInformation = String.Format("*:{0}:localhost", Properties.DevelopmentServerPort); |
||||
site.Bindings[0].BindingInformation = bindingInformation; |
||||
manager.CommitChanges(); |
||||
manager.Dispose(); |
||||
} |
||||
|
||||
protected override bool IsServerManagementVersionRequired(DomAssemblyName assemblyName) |
||||
{ |
||||
return (assemblyName.Version.Major == 7) && (assemblyName.Version.Minor == 9); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public static class IISExpressProcessStartInfo |
||||
{ |
||||
public static ProcessStartInfo Create(WebProject project) |
||||
{ |
||||
return new ProcessStartInfo(WebProjectService.IISExpressProcessLocation, GetSiteArgument(project)); |
||||
} |
||||
|
||||
static string GetSiteArgument(WebProject project) |
||||
{ |
||||
return String.Format("/site:{0}", project.Name); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.AspNet.Mvc |
||||
{ |
||||
public class NullIISAdministrator : IISAdministrator |
||||
{ |
||||
public NullIISAdministrator() |
||||
{ |
||||
} |
||||
|
||||
public override bool IsIISInstalled() |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public override void CreateVirtualDirectory(WebProject project) |
||||
{ |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue