Bug reports Found a bug? Post it here please.
Version 5.x > Bug reports > Macros don't resolve when you have multiple MacroHandlers? View modes: 
User avatar
Member
Member
jbarboza-wakefly - 2/9/2011 2:59:36 PM
   
Macros don't resolve when you have multiple MacroHandlers?
I have a custom macro resolver in a compiled assembly (Custom.MyResolver.dll, Custom.MyResolver). I've attached it to the MacroResolver.OnResolveCustomMacro event via:

MacroResolver.OnResolveCustomMacro +=
new MacroResolver.MacroHandler( Custom.MyResolver.ResolveMacro );

However, when my page loads in kentico my macro doesn't get resolved.

I noticed that a MacroHandler is bound in the CMSCustom.cs file and this seems to be causing my problem. This macro handler is running after mine and is setting match to false which it telling the underlying MacroResolver that no matches were made even though my macro handler has already done its work successfully.

I know that I can comment out the event binding in the CMSCustom.cs file but this looks like a bug with the MacroResolver since a handler has successfully handled the macro it shouldn't try the same macro with another handler.

Is there something that I am missing or is this how the MacroResolver is intended to function?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 2/10/2011 6:01:54 AM
   
RE:Macros don't resolve when you have multiple MacroHandlers?
Hi,

This behavior is typical for handlers. I mean, you can use a single event handler for multiple events.

The solution in your case is, as you said, comment out the event binding in CMSCustom.cs file.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
jbarboza-wakefly - 2/10/2011 8:32:35 AM
   
RE:Macros don't resolve when you have multiple MacroHandlers?
It is normal to use one event handler to handle many events - but then why is there a boolean out variable called "matched" on handler definition?

This implies to me that I can register multiple handlers and only if one fails to match an expression would the others be tried.

How was/is this matched variable intended to be used? Maybe I'm using it incorrectly.


User avatar
Member
Member
jbarboza-wakefly - 2/10/2011 10:01:18 AM
   
RE:Macros don't resolve when you have multiple MacroHandlers?
Nevermind, I realize my mistake. Is there going to be support for having multiple macroresolvers in future versions of Kentico?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 2/11/2011 6:29:09 AM
   
RE:Macros don't resolve when you have multiple MacroHandlers?
Hi,

Yes, you are right. This behavior should be optimized. I will create a requirement to change it in one of next versions.

Thank you for suggestions.

Best regards,
Ivana Tomanickova