Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete methods from INotifier #15631

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/OrchardCore/OrchardCore.DisplayManagement/Notify/INotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,16 @@ namespace OrchardCore.DisplayManagement.Notify
/// </remarks>
public interface INotifier
{
/// <summary>
/// Adds a new UI notification.
/// </summary>
/// <param name="type">
/// The type of the notification (notifications with different types can be displayed differently).</param>
/// <param name="message">A localized message to display.</param>
[Obsolete("This method will be removed in a later version. Use AddAsync()")]
void Add(NotifyType type, LocalizedHtmlString message);

/// <summary>
/// Adds a new UI notification asynchronously.
/// </summary>
/// <param name="type">
/// The type of the notification (notifications with different types can be displayed differently).</param>
/// <param name="message">A localized message to display.</param>
/// <remarks>
/// Added with a default interface implementation for backwards compatability.
/// Added with a default interface implementation for backwards compatibility.
/// </remarks>
ValueTask AddAsync(NotifyType type, LocalizedHtmlString message)
{
#pragma warning disable CS0618 // Type or member is obsolete
Add(type, message);
#pragma warning restore CS0618 // Type or member is obsolete

return new ValueTask();
}
ValueTask AddAsync(NotifyType type, LocalizedHtmlString message);

/// <summary>
/// Get all notifications added.
Expand Down
15 changes: 2 additions & 13 deletions src/OrchardCore/OrchardCore.DisplayManagement/Notify/Notifier.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.Extensions.Logging;

Expand All @@ -17,26 +16,16 @@ public Notifier(ILogger<Notifier> logger)
_logger = logger;
}

public void Add(NotifyType type, LocalizedHtmlString message)
{
throw new System.NotImplementedException();
}

public ValueTask AddAsync(NotifyType type, LocalizedHtmlString message)
{
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Notification '{NotificationType}' with message '{NotificationMessage}'", type, message.ToString());
}
_logger.LogInformation("Notification '{type}' with message '{message}'", type, message);

_entries.Add(new NotifyEntry { Type = type, Message = message });

return ValueTask.CompletedTask;
}

public IList<NotifyEntry> List()
{
return _entries;
}
=> _entries;
}
}
Loading