Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • wgaddis 6 posts 76 karma points
    6 days ago
    wgaddis
    0

    FileService event handlers

    Hello, I've been trying to implement an event handler for the FileService event SavedTemplate (to make a log of template modifications). I'm following the documentation as closely as I can, but when I try to add my handler to the savedTemplate property of the FileService class, I get a

    No overload for "my_handler" matches delegate TypedEventHandler

    My handler signature looks like this:

    private void Saved_Template(IFileService service, SaveEventArgs

    and I don't really see anything in the docs that point to anything more concrete for what my method signature should look like. What am I missing here?

  • Kevin Jump 1255 posts 7641 karma points MVP 2x c-trib
    6 days ago
    Kevin Jump
    0

    Hi,

    not 100% sure what you have (the forums have messed the code up a bit).

    but your register event should look like this.

    FileService.SavedTemplate += FileService_SavedTemplate;
    

    with you're handler function looking like this :

        private void FileService_SavedTemplate(IFileService sender, Umbraco.Core.Events.SaveEventArgs<ITemplate> e)
        {
            /// do stuff here
        }
    

    You can see this in how uSync tracks template changes here : https://github.com/KevinJump/uSync/blob/v4_master/Jumoo.uSync.BackOffice/Handlers/TemplateHandler.cs#L108

  • wgaddis 6 posts 76 karma points
    43 minutes ago
    wgaddis
    0

    I found a naming collision (Umbraco.Core.Events wasn't working due to a namespace *.Umbraco.Template in my solution), but I fixed it and I'm still getting the delegate matching error when trying to assign the custom handler.

  • wgaddis 6 posts 76 karma points
    7 hours ago
    wgaddis
    0

    Yeah, that's identical to what I have (only difference is not fully qualifying the namespace for SaveEventArgs, which intellisense says it's getting the correct one).

    Still getting the "no overload matches the delete" error on the FileService.SavedTemplate assignment when I'm calling it in an override for ApplicationStarted.

Please Sign in or register to post replies

Write your reply to:

Draft