Skip to content

Commit 3ff60a4

Browse files
committed
Register default implementations on other platforms
1 parent 91abdda commit 3ff60a4

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

src/Components/WebAssembly/WebAssembly/src/Hosting/WebAssemblyHostBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,6 @@ internal void InitializeDefaultServices()
262262
builder.AddProvider(new WebAssemblyConsoleLoggerProvider(DefaultWebAssemblyJSRuntime.Instance));
263263
});
264264
Services.AddSingleton<FormDataProvider, DefaultFormDataProvider>();
265+
Services.AddSingleton<IFormValueSupplier, WebAssemblyFormValueSupplier>();
265266
}
266267
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics.CodeAnalysis;
5+
using Microsoft.AspNetCore.Components.Binding;
6+
7+
namespace Microsoft.AspNetCore.Components.WebAssembly.Services;
8+
internal class WebAssemblyFormValueSupplier : IFormValueSupplier
9+
{
10+
public bool CanBind(string formName, Type valueType)
11+
{
12+
return false;
13+
}
14+
15+
public bool TryBind(string formName, Type valueType, [NotNullWhen(true)] out object? boundValue)
16+
{
17+
boundValue = null;
18+
return false;
19+
}
20+
}

src/Components/WebView/WebView/src/ComponentsWebViewServiceCollectionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public static IServiceCollection AddBlazorWebView(this IServiceCollection servic
3131
services.TryAddScoped<NavigationManager, WebViewNavigationManager>();
3232
services.TryAddScoped<IErrorBoundaryLogger, WebViewErrorBoundaryLogger>();
3333
services.TryAddScoped<FormDataProvider, DefaultFormDataProvider>();
34+
services.TryAddScoped<IFormValueSupplier, WebViewFormValueSupplier>();
35+
3436
return services;
3537
}
3638
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics.CodeAnalysis;
5+
using Microsoft.AspNetCore.Components.Binding;
6+
7+
namespace Microsoft.AspNetCore.Components.WebView.Services;
8+
9+
internal class WebViewFormValueSupplier : IFormValueSupplier
10+
{
11+
public bool CanBind(string formName, Type valueType)
12+
{
13+
return false;
14+
}
15+
16+
public bool TryBind(string formName, Type valueType, [NotNullWhen(true)] out object? boundValue)
17+
{
18+
boundValue = null;
19+
return false;
20+
}
21+
}

0 commit comments

Comments
 (0)