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
moduleBuilder.RegisterType<CastleLoggerFactory>().As<ILoggerFactory>().InstancePerLifetimeScope();
try {
// by default, use Castle's TraceSource based logger factory
new SecurityPermission(SecurityPermissionFlag.ControlEvidence | SecurityPermissionFlag.ControlPolicy).Demand();
// Register logger type
if (AppDomain.CurrentDomain.IsHomogenous && AppDomain.CurrentDomain.IsFullyTrusted) {
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
moduleBuilder.RegisterType<NullLogFactory>().As<Castle.Core.Logging.ILoggerFactory>().InstancePerLifetimeScope();
}