Medium Trust: Testing for full trust instead of demanding permission to avoid secannotate warning.

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-11-11 14:54:58 -08:00
parent e6324ea43e
commit 4890c79d96

View File

@@ -16,11 +16,10 @@ namespace Orchard.Logging {
// by default, use Orchard's logger that delegates to Castle's logger factory // by default, use Orchard's logger that delegates to Castle's logger factory
moduleBuilder.RegisterType<CastleLoggerFactory>().As<ILoggerFactory>().InstancePerLifetimeScope(); moduleBuilder.RegisterType<CastleLoggerFactory>().As<ILoggerFactory>().InstancePerLifetimeScope();
try { // Register logger type
// by default, use Castle's TraceSource based logger factory if (AppDomain.CurrentDomain.IsHomogenous && AppDomain.CurrentDomain.IsFullyTrusted) {
new SecurityPermission(SecurityPermissionFlag.ControlEvidence | SecurityPermissionFlag.ControlPolicy).Demand();
moduleBuilder.RegisterType<TraceLoggerFactory>().As<Castle.Core.Logging.ILoggerFactory>().InstancePerLifetimeScope(); moduleBuilder.RegisterType<TraceLoggerFactory>().As<Castle.Core.Logging.ILoggerFactory>().InstancePerLifetimeScope();
} catch (SecurityException) { } else {
// if security model does not allow it, fall back to null logger factory // if security model does not allow it, fall back to null logger factory
moduleBuilder.RegisterType<NullLogFactory>().As<Castle.Core.Logging.ILoggerFactory>().InstancePerLifetimeScope(); moduleBuilder.RegisterType<NullLogFactory>().As<Castle.Core.Logging.ILoggerFactory>().InstancePerLifetimeScope();
} }