mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
Medium Trust: Replacing usage of GetName() by assemblyName on commandhostenvironment. Extracting DefaultHostEnvironment class to a file outside of the Interface one.
--HG-- branch : dev
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Web.Hosting;
|
using System.Web.Hosting;
|
||||||
using Orchard.Environment;
|
using Orchard.Environment;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
@@ -21,7 +22,7 @@ namespace Orchard.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool IsAssemblyLoaded(string name) {
|
public bool IsAssemblyLoaded(string name) {
|
||||||
return AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == name);
|
return AppDomain.CurrentDomain.GetAssemblies().Any(assembly => new AssemblyName(assembly.FullName).Name == name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RestartAppDomain() {
|
public void RestartAppDomain() {
|
||||||
|
64
src/Orchard/Environment/DefaultHostEnvironment.cs
Normal file
64
src/Orchard/Environment/DefaultHostEnvironment.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Hosting;
|
||||||
|
using Orchard.Services;
|
||||||
|
using Orchard.Utility.Extensions;
|
||||||
|
|
||||||
|
namespace Orchard.Environment
|
||||||
|
{
|
||||||
|
public class DefaultHostEnvironment : IHostEnvironment
|
||||||
|
{
|
||||||
|
private readonly IClock _clock;
|
||||||
|
|
||||||
|
public DefaultHostEnvironment(IClock clock)
|
||||||
|
{
|
||||||
|
_clock = clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsFullTrust
|
||||||
|
{
|
||||||
|
get { return AppDomain.CurrentDomain.IsFullyTrusted; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string MapPath(string virtualPath)
|
||||||
|
{
|
||||||
|
return HostingEnvironment.MapPath(virtualPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsAssemblyLoaded(string name)
|
||||||
|
{
|
||||||
|
return AppDomain.CurrentDomain.GetAssemblies().Any(assembly => new AssemblyName(assembly.FullName).Name == name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RestartAppDomain()
|
||||||
|
{
|
||||||
|
ResetSiteCompilation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetSiteCompilation()
|
||||||
|
{
|
||||||
|
// Touch web.config
|
||||||
|
File.SetLastWriteTimeUtc(MapPath("~/web.config"), _clock.UtcNow);
|
||||||
|
|
||||||
|
// If setting up extensions/modules requires an AppDomain restart, it's very unlikely the
|
||||||
|
// current request can be processed correctly. So, we redirect to the same URL, so that the
|
||||||
|
// new request will come to the newly started AppDomain.
|
||||||
|
if (HttpContext.Current != null)
|
||||||
|
{
|
||||||
|
// Don't redirect posts...
|
||||||
|
if (HttpContext.Current.Request.RequestType == "GET")
|
||||||
|
{
|
||||||
|
HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ToUrlString(), true /*endResponse*/);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HttpContext.Current.Response.WriteFile("~/Refresh.html");
|
||||||
|
HttpContext.Current.Response.End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,13 +1,4 @@
|
|||||||
using System;
|
namespace Orchard.Environment {
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Web;
|
|
||||||
using System.Web.Hosting;
|
|
||||||
using Orchard.Services;
|
|
||||||
using Orchard.Utility.Extensions;
|
|
||||||
|
|
||||||
namespace Orchard.Environment {
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Abstraction of the running environment
|
/// Abstraction of the running environment
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -20,47 +11,4 @@ namespace Orchard.Environment {
|
|||||||
void RestartAppDomain();
|
void RestartAppDomain();
|
||||||
void ResetSiteCompilation();
|
void ResetSiteCompilation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DefaultHostEnvironment : IHostEnvironment {
|
|
||||||
private readonly IClock _clock;
|
|
||||||
|
|
||||||
public DefaultHostEnvironment(IClock clock) {
|
|
||||||
_clock = clock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsFullTrust {
|
|
||||||
get { return AppDomain.CurrentDomain.IsFullyTrusted; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string MapPath(string virtualPath) {
|
|
||||||
return HostingEnvironment.MapPath(virtualPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsAssemblyLoaded(string name) {
|
|
||||||
return AppDomain.CurrentDomain.GetAssemblies().Any(assembly => new AssemblyName(assembly.FullName).Name == name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RestartAppDomain() {
|
|
||||||
ResetSiteCompilation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetSiteCompilation() {
|
|
||||||
// Touch web.config
|
|
||||||
File.SetLastWriteTimeUtc(MapPath("~/web.config"), _clock.UtcNow);
|
|
||||||
|
|
||||||
// If setting up extensions/modules requires an AppDomain restart, it's very unlikely the
|
|
||||||
// current request can be processed correctly. So, we redirect to the same URL, so that the
|
|
||||||
// new request will come to the newly started AppDomain.
|
|
||||||
if (HttpContext.Current != null) {
|
|
||||||
// Don't redirect posts...
|
|
||||||
if (HttpContext.Current.Request.RequestType == "GET") {
|
|
||||||
HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ToUrlString(), true /*endResponse*/);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
HttpContext.Current.Response.WriteFile("~/Refresh.html");
|
|
||||||
HttpContext.Current.Response.End();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -174,6 +174,7 @@
|
|||||||
<Compile Include="DisplayManagement\Implementation\IShapeDisplayEvents.cs" />
|
<Compile Include="DisplayManagement\Implementation\IShapeDisplayEvents.cs" />
|
||||||
<Compile Include="DisplayManagement\Implementation\IShapeFactoryEvents.cs" />
|
<Compile Include="DisplayManagement\Implementation\IShapeFactoryEvents.cs" />
|
||||||
<Compile Include="DisplayManagement\Shapes\ITagBuilderFactory.cs" />
|
<Compile Include="DisplayManagement\Shapes\ITagBuilderFactory.cs" />
|
||||||
|
<Compile Include="Environment\DefaultHostEnvironment.cs" />
|
||||||
<Compile Include="Environment\Extensions\Loaders\RawThemeExtensionLoader.cs" />
|
<Compile Include="Environment\Extensions\Loaders\RawThemeExtensionLoader.cs" />
|
||||||
<Compile Include="Environment\Features\FeatureManager.cs" />
|
<Compile Include="Environment\Features\FeatureManager.cs" />
|
||||||
<Compile Include="Localization\Services\DefaultLocalizedStringManager.cs" />
|
<Compile Include="Localization\Services\DefaultLocalizedStringManager.cs" />
|
||||||
|
Reference in New Issue
Block a user