Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15519,6 +15519,13 @@
By default, the tooltip closes if the cursor leaves the anchor, but not the tooltip itself.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.LibraryConfiguration.ServiceLifetime">
<summary>
Gets or sets the service lifetime for the library services, when using Fluent UI in WebAssembly, it can make sense to use <see cref="F:Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton"/>.
Default is <see cref="F:Microsoft.Extensions.DependencyInjection.ServiceLifetime.Scoped"/>.
<para>Only <see cref="F:Microsoft.Extensions.DependencyInjection.ServiceLifetime.Scoped"/> and <see cref="F:Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton"/> are supported.</para>
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.LibraryConfiguration.ValidateClassNames">
<summary>
Gets or sets the value indicating whether the library should validate CSS class names.
Expand Down
1 change: 0 additions & 1 deletion src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public abstract partial class ColumnBase<TGridItem>
[Parameter]
public string? Title { get; set; }


/// <summary>
/// Gets or sets the index (1-based) of the column
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion src/Core/Enums/DataGridRowSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public enum DataGridRowSize
/// </summary>
Medium = 44,


/// <summary>
/// Smaller row height
/// </summary>
Expand Down
38 changes: 31 additions & 7 deletions src/Core/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,41 @@ public static class ServiceCollectionExtensions
/// <param name="configuration">Library configuration</param>
public static IServiceCollection AddFluentUIComponents(this IServiceCollection services, LibraryConfiguration? configuration = null)
{
services.AddScoped<GlobalState>();
services.AddScoped<IToastService, ToastService>();
services.AddScoped<IDialogService, DialogService>();
services.AddScoped<IMessageService, MessageService>();
services.AddScoped<IKeyCodeService, KeyCodeService>();
services.AddScoped<IMenuService, MenuService>();
var serviceLifetime = configuration?.ServiceLifetime ?? ServiceLifetime.Scoped;
if (serviceLifetime == ServiceLifetime.Transient)
{
throw new NotSupportedException("Transient lifetime is not supported for Fluent UI services.");
}
if (serviceLifetime == ServiceLifetime.Singleton)
{
services.AddSingleton<GlobalState>();
services.AddSingleton<IToastService, ToastService>();
services.AddSingleton<IDialogService, DialogService>();
services.AddSingleton<IMessageService, MessageService>();
services.AddSingleton<IKeyCodeService, KeyCodeService>();
services.AddSingleton<IMenuService, MenuService>();
}
else
{
services.AddScoped<GlobalState>();
services.AddScoped<IToastService, ToastService>();
services.AddScoped<IDialogService, DialogService>();
services.AddScoped<IMessageService, MessageService>();
services.AddScoped<IKeyCodeService, KeyCodeService>();
services.AddScoped<IMenuService, MenuService>();
}

var options = configuration ?? new();
if (options.UseTooltipServiceProvider)
{
services.AddScoped<ITooltipService, TooltipService>();
if (serviceLifetime == ServiceLifetime.Singleton)
{
services.AddSingleton<ITooltipService, TooltipService>();
}
else
{
services.AddScoped<ITooltipService, TooltipService>();
}
}
services.AddSingleton(options);

Expand Down
8 changes: 8 additions & 0 deletions src/Core/Infrastructure/LibraryConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.FluentUI.AspNetCore.Components;

Expand Down Expand Up @@ -34,6 +35,13 @@ public class LibraryConfiguration
/// </summary>
public bool HideTooltipOnCursorLeave { get; set; } = false;

/// <summary>
/// Gets or sets the service lifetime for the library services, when using Fluent UI in WebAssembly, it can make sense to use <see cref="ServiceLifetime.Singleton"/>.
/// Default is <see cref="ServiceLifetime.Scoped"/>.
/// <para>Only <see cref="ServiceLifetime.Scoped"/> and <see cref="ServiceLifetime.Singleton"/> are supported.</para>
/// </summary>
public ServiceLifetime ServiceLifetime { get; set; } = ServiceLifetime.Scoped;

/// <summary>
/// Gets or sets the value indicating whether the library should validate CSS class names.
/// respecting the following regex: "^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$".
Expand Down
Loading