You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class SubscribeToSavedEventComponent : IComponent
{
private readonly ILogger _logger;
public SubscribeToSavedEventComponent(ILogger logger)
{
this._logger = logger;
}
public void Initialize()
{
//specify my event handler
MemberService.Saved += MemberService_Saved;
}
private void MemberService_Saved(IMemberService sender, SaveEventArgs<IMember> e)
{
foreach (var member in e.SavedEntities)
{
//write to the logs every time a member is saved
this._logger.Info<MyPublishEventComponent>("member {member} has been saved and event fired!", member.Name);
}
}
public void Terminate()
{
// Nothing to terminate
}
should be
public class SubscribeToSavedEventComponent : IComponent
{
private readonly ILogger _logger;
public SubscribeToSavedEventComponent(ILogger logger)
{
this._logger = logger;
}
public void Initialize()
{
//specify my event handler
MemberService.Saved += MemberService_Saved;
}
private void MemberService_Saved(IMemberService sender, SaveEventArgs<IMember> e)
{
foreach (var member in e.SavedEntities)
{
//write to the logs every time a member is saved
this._logger.Info<MyPublishEventComponent>("member {member} has been saved and event fired!", member.Name);
}
}
public void Terminate()
{
//unsubscribe to event during shutdown
MemberService.Saved -= MemberService_Saved;
}
eg this sort of example:
public class SubscribeToSavedEventComponent : IComponent
{
private readonly ILogger _logger;
should be
public class SubscribeToSavedEventComponent : IComponent
{
private readonly ILogger _logger;
See this PR for context: umbraco/Umbraco-CMS#8815
The text was updated successfully, but these errors were encountered: