Skip to content

Commit b2bd243

Browse files
Add constructor to componentasdialogoptions
1 parent 5288db4 commit b2bd243

12 files changed

Lines changed: 37 additions & 46 deletions

File tree

BlazorDialog.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1111
.gitattributes = .gitattributes
1212
.gitignore = .gitignore
1313
build.ps1 = build.ps1
14+
Directory.Build.props = Directory.Build.props
1415
global.json = global.json
1516
README.md = README.md
1617
EndProjectSection

BlazorDialog/IBlazorDialogStore.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ namespace BlazorDialog
88
{
99
public class ComponentAsDialogOptions
1010
{
11+
public ComponentAsDialogOptions(Type componentType)
12+
{
13+
ComponentType = componentType;
14+
}
15+
1116
/// <summary>
1217
/// The type of the rendered component
1318
/// </summary>
14-
public Type ComponentType { get; set; }
19+
public Type ComponentType { get; protected set; }
1520

1621
/// <summary>
1722
/// The parameters of the rendered component.
@@ -41,7 +46,7 @@ public class ComponentAsDialogOptions
4146
/// <summary>
4247
/// Adds a custom css class to the wrapper of the dialog.
4348
/// </summary>
44-
public string CssClass { get; set; }
49+
public string? CssClass { get; set; }
4550

4651
/// <summary>
4752
/// Allows you to set the dialog size. Ignored when the dialog is <see cref="Dialog.IsCustom" />.

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<MSPackagesVersion>7.0.0</MSPackagesVersion>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
</PropertyGroup>
9+
</Project>

TestApps/BlazorDialog.TestAppsCommon/BlazorDialog.TestAppsCommon.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

3-
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
5-
</PropertyGroup>
63

74
<ItemGroup>
85
<SupportedPlatform Include="browser" />
96
</ItemGroup>
107

118
<ItemGroup>
12-
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0" />
9+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(MSPackagesVersion)" />
1310
</ItemGroup>
1411

1512

TestApps/BlazorDialog.TestAppsCommon/ComponentDialog.razor

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@
4242
private string dialogResult;
4343
protected async Task ShowInputDialog()
4444
{
45-
dialogResult = await dialogService.ShowComponentAsDialog<string>(new ComponentAsDialogOptions
45+
dialogResult = await dialogService.ShowComponentAsDialog<string>(new ComponentAsDialogOptions(typeof(ComponentDialogInput))
46+
{
47+
Parameters = new()
4648
{
47-
ComponentType = typeof(ComponentDialogInput),
48-
Parameters = new()
49-
{
50-
{ nameof(ComponentDialogInput.Input), "(Simple Dialog Large) Are you sure?"}
51-
}
52-
});
49+
{ nameof(ComponentDialogInput.Input), "(Simple Dialog Large) Are you sure?"}
50+
}
51+
});
5352
}
5453
}

TestApps/BlazorDialog.TestAppsCommon/ComponentDialogInput.razor

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414

1515
protected async Task ShowInputDialog()
1616
{
17-
await dialogService.ShowComponentAsDialog(new ComponentAsDialogOptions
17+
await dialogService.ShowComponentAsDialog(new ComponentAsDialogOptions(typeof(ComponentDialog))
1818
{
19-
ComponentType = typeof(ComponentDialog),
2019
Parameters = new()
21-
{
22-
{ nameof(ComponentDialog.Input), "(Simple Dialog) Are you sure?" }
23-
}
20+
{
21+
{ nameof(ComponentDialog.Input), "(Simple Dialog) Are you sure?" }
22+
}
2423
});
2524
}
2625
}

TestApps/BlazorDialog.TestAppsCommon/ComponentsAsDialogsCommon.razor

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,25 @@
3939

4040
async Task SimpleDialogOnClick()
4141
{
42-
await dialogService.ShowComponentAsDialog(new ComponentAsDialogOptions
42+
await dialogService.ShowComponentAsDialog(new ComponentAsDialogOptions(typeof(ComponentDialog))
4343
{
4444
Animation = animation,
4545
Size = size,
4646
Centered = isCentered,
47-
ComponentType = typeof(ComponentDialog),
4847
Parameters = new()
49-
{
50-
{ nameof(ComponentDialog.Input), "(Simple Dialog) Are you sure?" }
51-
}
48+
{
49+
{ nameof(ComponentDialog.Input), "(Simple Dialog) Are you sure?" }
50+
}
5251
});
5352
}
5453

5554
async Task SimpleDialogWithResultOnClick()
5655
{
57-
dialogResult = await dialogService.ShowComponentAsDialog<string>(new ComponentAsDialogOptions
56+
dialogResult = await dialogService.ShowComponentAsDialog<string>(new ComponentAsDialogOptions(typeof(ComponentDialogInput))
5857
{
5958
Animation = animation,
6059
Size = size,
6160
Centered = isCentered,
62-
ComponentType = typeof(ComponentDialogInput),
6361
Parameters = new()
6462
{
6563
{ nameof(ComponentDialogInput.Input), "(Simple Dialog Large) Are you sure?"}

TestApps/Server/BlazorDialog.BlazorServerTestApp/BlazorDialog.BlazorServerTestApp.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

3-
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
5-
</PropertyGroup>
6-
73
<ItemGroup>
84
<ProjectReference Include="..\..\..\BlazorDialog\BlazorDialog.csproj" />
95
<ProjectReference Include="..\..\BlazorDialog.TestAppsCommon\BlazorDialog.TestAppsCommon.csproj" />

TestApps/Wasm/BlazorDialog.BlazorTestApp.Client/BlazorDialog.BlazorTestApp.Client.csproj

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22

3-
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
5-
<Nullable>enable</Nullable>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
</PropertyGroup>
8-
93
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0" />
11-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0" PrivateAssets="all" />
4+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(MSPackagesVersion)" />
5+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="$(MSPackagesVersion)" PrivateAssets="all" />
126
</ItemGroup>
137

148
<ItemGroup>

TestApps/Wasm/BlazorDialog.BlazorTestApp.Client/Pages/ComponentsAsDialogs.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
<ComponentsAsDialogsCommon />
44

5-
<BlazorDialog.Components.ComponentDialogsOutput />
5+
<DialogOutput />

0 commit comments

Comments
 (0)