-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bitfoundation:develop' into 7761-dotnet9-rc2
- Loading branch information
Showing
67 changed files
with
565 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...late/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Extensions/ByteArrayExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace System; | ||
|
||
public static class ByteArrayExtensions | ||
{ | ||
public static string ToStampString(this byte[]? source) | ||
{ | ||
if (source is null or { Length: 0 }) | ||
source = [0, 0, 0, 0, 0, 0, 0, 0]; | ||
|
||
var base64String = Convert.ToBase64String(source); | ||
|
||
return Uri.EscapeDataString(base64String); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...it.Boilerplate/src/Client/Boilerplate.Client.Core/Extensions/ILoggingBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Microsoft.Extensions.Logging; | ||
|
||
public static class ILoggingBuilderExtensions | ||
{ | ||
public static ILoggingBuilder AddBrowserConsoleLogger(this ILoggingBuilder builder) | ||
{ | ||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, BrowserConsoleLoggerProvider>()); | ||
|
||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...t.Boilerplate/src/Client/Boilerplate.Client.Core/Services/BrowserConsoleLoggerProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
//+:cnd:noEmit | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Boilerplate.Client.Core.Services; | ||
|
||
// https://learn.microsoft.com/en-us/aspnet/core/blazor/hybrid/developer-tools | ||
|
||
/// <summary> | ||
/// This logger writes to the browser console in blazor hybrid. | ||
/// </summary> | ||
[ProviderAlias("BrowserConsolelogger")] | ||
public partial class BrowserConsoleLoggerProvider : ILoggerProvider, ILogger, IDisposable | ||
{ | ||
private static Bit.Butil.Console? console; | ||
|
||
public static void SetConsole(Bit.Butil.Console console) | ||
{ | ||
if (AppPlatform.IsBlazorHybrid is false) | ||
throw new InvalidOperationException(); | ||
BrowserConsoleLoggerProvider.console = console; | ||
} | ||
|
||
public string? CategoryName { get; init; } | ||
|
||
private static readonly ConcurrentQueue<object> states = new(); | ||
|
||
public ILogger CreateLogger(string categoryName) | ||
{ | ||
return new BrowserConsoleLoggerProvider | ||
{ | ||
CategoryName = categoryName | ||
}; | ||
} | ||
|
||
public IDisposable? BeginScope<TState>(TState state) | ||
where TState : notnull | ||
{ | ||
if (state is IDictionary<string, object?> dictionary) | ||
{ | ||
dictionary["Category"] = CategoryName; | ||
} | ||
|
||
states.Enqueue(state); | ||
|
||
return this; | ||
} | ||
|
||
public bool IsEnabled(LogLevel logLevel) | ||
{ | ||
return AppPlatform.IsBlazorHybrid | ||
&& console is not null; | ||
} | ||
|
||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter) | ||
{ | ||
if (IsEnabled(logLevel) is false) return; | ||
|
||
var message = formatter(state, exception); | ||
|
||
var currentState = states.TryDequeue(out var stateFromQueue) ? stateFromQueue : state; | ||
|
||
switch (logLevel) | ||
{ | ||
case LogLevel.Trace: | ||
case LogLevel.Debug: | ||
console!.Log(message, $"{Environment.NewLine}State:", currentState); | ||
break; | ||
case LogLevel.Information: | ||
console!.Info(message, $"{Environment.NewLine}State:", currentState); | ||
break; | ||
case LogLevel.Warning: | ||
console!.Warn(message, $"{Environment.NewLine}State:", currentState); | ||
break; | ||
case LogLevel.Error: | ||
case LogLevel.Critical: | ||
console!.Error(message, $"{Environment.NewLine}State:", currentState); | ||
break; | ||
case LogLevel.None: | ||
break; | ||
default: | ||
console!.Log(message, $"{Environment.NewLine}State:", currentState); | ||
break; | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
states.TryDequeue(out _); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 8 additions & 14 deletions
22
...it.Boilerplate/src/Client/Boilerplate.Client.Core/Services/PushNotificationServiceBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.