Skip to content

Commit ef8013f

Browse files
committed
1.1.9.2
1 parent a520c8f commit ef8013f

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed
-87.2 KB
Binary file not shown.
87.6 KB
Binary file not shown.

Blazor.WebForm.Components/Base/ControlParameterViewComponentExtensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,19 @@ public static ITemplate GetInsertTemplateProperty<TValue>(this IParameterViewCom
182182
}
183183
}
184184

185+
public static ITemplate GetEditTemplateProperty<TValue>(this IParameterViewComponent component, RenderFragment<TValue> value)
186+
where TValue : class, new()
187+
{
188+
if (value != null)
189+
{
190+
return new RenderFragmentBindableTemplateBuilder<TValue>(value, ExtractValues, context => new TValue().Apply(() => context));
191+
}
192+
else
193+
{
194+
return null;
195+
}
196+
}
197+
185198
private static IOrderedDictionary ExtractValues<TValue>(Control container, TValue context)
186199
{
187200
return new OrderedDictionary().Apply(() => context);

Blazor.WebForm.Components/Blazor.WebForm.Components.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net5.0</TargetFramework>
55
<SignAssembly>true</SignAssembly>
66
<AssemblyOriginatorKeyFile>Blazor.WebForm.Components.pfx</AssemblyOriginatorKeyFile>
7-
<Version>1.1.9.1</Version>
7+
<Version>1.1.9.2</Version>
88
<RootNamespace>asp</RootNamespace>
99
<Copyright>Jurio li</Copyright>
1010
<AssemblyName>Blazor.WebForm.Components</AssemblyName>
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="Applied" Version="1.2.1.5" />
20-
<PackageReference Include="Blazor.WebForm.UI" Version="1.1.9.1" />
20+
<PackageReference Include="Blazor.WebForm.UI" Version="1.1.9.2" />
2121
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.8" />
2222
</ItemGroup>
2323

Blazor.WebForm.Components/Inner/Common/EditItemTemplate.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Blazor.WebForm.UI.PropertyComponents;
1+
using Blazor.WebForm.UI;
2+
using Blazor.WebForm.UI.PropertyComponents;
23
using System;
34
using System.Collections.Generic;
45
using System.Linq;
@@ -8,13 +9,26 @@
89
namespace Microsoft.AspNetCore.Components
910
{
1011
public partial class EditItemTemplate<TItem> : BindableTemplatePropertyComponent<object, TItem>, ICommonPropertyComponent
12+
where TItem : class, new()
1113
{
14+
[Parameter]
15+
public bool SubstituteItem { get; set; } = true;
16+
1217
protected override string PropertyName
1318
{
1419
get
1520
{
1621
return nameof(EditItemTemplate<TItem>);
1722
}
1823
}
24+
25+
protected override KeyValuePair<string, object>? OnConvertParameter(KeyValuePair<string, object> parameter)
26+
{
27+
if (parameter.Key == nameof(this.ChildContent) && this.SubstituteItem)
28+
{
29+
return new KeyValuePair<string, object>(this.PropertyName, this.GetEditTemplateProperty(this.ChildContent));
30+
}
31+
return base.OnConvertParameter(parameter);
32+
}
1933
}
2034
}

0 commit comments

Comments
 (0)