Moved type helper methods from TypeFinder2 to TypeHelper. Created SystemUtilities for detecting
app trust levels. Updated all calls to TypeFinder to TypeFinder2 and updated tests.
This commit is contained in:
40
src/Umbraco.Core/SystemUtilities.cs
Normal file
40
src/Umbraco.Core/SystemUtilities.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Security;
|
||||
using System.Web;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Static helper methods for returning information about the current System
|
||||
/// </summary>
|
||||
public static class SystemUtilities
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Get the current trust level of the hosted application
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static AspNetHostingPermissionLevel GetCurrentTrustLevel()
|
||||
{
|
||||
foreach (var trustLevel in new[] {
|
||||
AspNetHostingPermissionLevel.Unrestricted,
|
||||
AspNetHostingPermissionLevel.High,
|
||||
AspNetHostingPermissionLevel.Medium,
|
||||
AspNetHostingPermissionLevel.Low,
|
||||
AspNetHostingPermissionLevel.Minimal })
|
||||
{
|
||||
try
|
||||
{
|
||||
new AspNetHostingPermission(trustLevel).Demand();
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return trustLevel;
|
||||
}
|
||||
|
||||
return AspNetHostingPermissionLevel.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user