From dcd5decd3a5ba94ebf6d11b2b74f77d4ca24c341 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 12 Sep 2013 14:55:29 +1000 Subject: [PATCH] Fixes up the events in the new MacroRendering event stuff --- src/Umbraco.Web/umbraco.presentation/macro.cs | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/macro.cs b/src/Umbraco.Web/umbraco.presentation/macro.cs index a3348e76a2..a457ceac72 100644 --- a/src/Umbraco.Web/umbraco.presentation/macro.cs +++ b/src/Umbraco.Web/umbraco.presentation/macro.cs @@ -231,19 +231,31 @@ namespace umbraco return renderMacro(pageElements, pageId); } - public delegate void OnMacroRenderingEventHandler(macro sender, EventArgs e); - public static event OnMacroRenderingEventHandler OnMacroRendering; - protected void FireOnMacroRendering(EventArgs e) + /// + /// An event that is raised just before the macro is rendered allowing developers to modify the macro before it executes. + /// + public static event TypedEventHandler MacroRendering; + + /// + /// Raises the MacroRendering event + /// + /// + protected void OnMacroRendering(MacroRenderingEventArgs e) { - if (OnMacroRendering != null) - OnMacroRendering(this, e); + if (MacroRendering != null) + MacroRendering(this, e); } + /// + /// Renders the macro + /// + /// + /// + /// public Control renderMacro(Hashtable pageElements, int pageId) { // Event to allow manipulation of Macro Model - var rea = new EventArgs(); - FireOnMacroRendering(rea); + OnMacroRendering(new MacroRenderingEventArgs(pageElements, pageId)); var macroInfo = (Model.MacroType == MacroTypes.Script && Model.Name.IsNullOrWhiteSpace()) ? string.Format("Render Inline Macro, Cache: {0})", Model.CacheDuration) @@ -1964,6 +1976,20 @@ namespace umbraco #endregion } - public class MacroRenderingEventArgs : System.EventArgs { } + + /// + /// Event arguments used for the MacroRendering event + /// + public class MacroRenderingEventArgs : EventArgs + { + public Hashtable PageElements { get; private set; } + public int PageId { get; private set; } + + public MacroRenderingEventArgs(Hashtable pageElements, int pageId) + { + PageElements = pageElements; + PageId = pageId; + } + } } \ No newline at end of file