Preventing modules from breaking the website if a referenced assembly is missing

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-11-30 17:43:09 -08:00
parent f5810823fb
commit 9380e2c4a6
11 changed files with 94 additions and 26 deletions

View File

@@ -0,0 +1,24 @@
using System.Linq;
using System.Collections.Generic;
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.UI.Admin.Notification;
using Orchard.UI.Notify;
namespace Orchard.Core.Dashboard.Services {
public class CompilationErrorBanner : INotificationProvider {
private readonly ICriticalErrorProvider _errorProvider;
public CompilationErrorBanner(ICriticalErrorProvider errorProvider) {
_errorProvider = errorProvider;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
public IEnumerable<NotifyEntry> GetNotifications() {
return _errorProvider.GetErrors()
.Select(message => new NotifyEntry { Message = message, Type = NotifyType.Error });
}
}
}

View File

@@ -124,6 +124,7 @@
<Compile Include="Contents\Settings\ContentPartSettings.cs" />
<Compile Include="Contents\Shapes.cs" />
<Compile Include="Contents\ViewModels\PublishContentViewModel.cs" />
<Compile Include="Dashboard\Services\CompilationErrorBanner.cs" />
<Compile Include="Navigation\Commands\MenuCommands.cs" />
<Compile Include="Navigation\Drivers\AdminMenuPartDriver.cs" />
<Compile Include="Navigation\Handlers\AdminMenuPartHandler.cs" />

View File

@@ -1 +1 @@
<div class="message message-@Model.Type">@Model.Message</div>
<div class="message message-@Model.Type">@Html.Raw(Html.Encode(Model.Message).Replace("\n", "<br />"))</div>