From d63a9ed9d1e6f3e3d1b36975bab1c8274457e534 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 3 Nov 2015 20:38:57 +0100 Subject: [PATCH] Updated ElementDisplay to use Invoke extension method. The generic Invoke extension method has the advantage of catching any exceptions occurring in client code and logging them, preventing the rest of the Layouts from breaking down. --- .../Framework/Display/ElementDisplay.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Display/ElementDisplay.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Display/ElementDisplay.cs index e9950e6b0..3d88c4f6c 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Display/ElementDisplay.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Display/ElementDisplay.cs @@ -4,7 +4,6 @@ using System.Linq; using Orchard.ContentManagement; using Orchard.DisplayManagement; using Orchard.Layouts.Elements; -using Orchard.Layouts.Framework.Drivers; using Orchard.Layouts.Framework.Elements; using Orchard.Layouts.Services; using Orchard.UI.Zones; @@ -12,7 +11,7 @@ using Orchard.Utility.Extensions; using ContentItem = Orchard.ContentManagement.ContentItem; namespace Orchard.Layouts.Framework.Display { - public class ElementDisplay : IElementDisplay { + public class ElementDisplay : Component, IElementDisplay { private readonly IShapeFactory _shapeFactory; private readonly IElementEventHandler _elementEventHandlerHandler; @@ -37,7 +36,7 @@ namespace Orchard.Layouts.Framework.Display { }; _elementEventHandlerHandler.CreatingDisplay(createShapeContext); - InvokeDrivers(drivers, driver => driver.CreatingDisplay(createShapeContext)); + drivers.Invoke(driver => driver.CreatingDisplay(createShapeContext), Logger); if (element.Descriptor.CreatingDisplay != null) element.Descriptor.CreatingDisplay(createShapeContext); @@ -62,7 +61,7 @@ namespace Orchard.Layouts.Framework.Display { }; _elementEventHandlerHandler.Displaying(displayingContext); - InvokeDrivers(drivers, driver => driver.Displaying(displayingContext)); + drivers.Invoke(driver => driver.Displaying(displayingContext), Logger); if (element.Descriptor.Displaying != null) element.Descriptor.Displaying(displayingContext); @@ -92,7 +91,7 @@ namespace Orchard.Layouts.Framework.Display { }; _elementEventHandlerHandler.Displayed(displayedContext); - InvokeDrivers(drivers, driver => driver.Displayed(displayedContext)); + drivers.Invoke(driver => driver.Displayed(displayedContext), Logger); if (element.Descriptor.Displayed != null) element.Descriptor.Displayed(displayedContext); @@ -122,11 +121,5 @@ namespace Orchard.Layouts.Framework.Display { return Arguments.From(dictionary); } - - private void InvokeDrivers(IEnumerable drivers, Action driverAction) { - foreach (var driver in drivers) { - driverAction(driver); - } - } } } \ No newline at end of file