Skip to content

Commit

Permalink
1.1.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurioli committed Aug 30, 2021
1 parent a520c8f commit ef8013f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
Binary file removed Blazor.WebForm.Components.1.1.9.1.nupkg
Binary file not shown.
Binary file added Blazor.WebForm.Components.1.1.9.2.nupkg
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,19 @@ public static ITemplate GetInsertTemplateProperty<TValue>(this IParameterViewCom
}
}

public static ITemplate GetEditTemplateProperty<TValue>(this IParameterViewComponent component, RenderFragment<TValue> value)
where TValue : class, new()
{
if (value != null)
{
return new RenderFragmentBindableTemplateBuilder<TValue>(value, ExtractValues, context => new TValue().Apply(() => context));
}
else
{
return null;
}
}

private static IOrderedDictionary ExtractValues<TValue>(Control container, TValue context)
{
return new OrderedDictionary().Apply(() => context);
Expand Down
4 changes: 2 additions & 2 deletions Blazor.WebForm.Components/Blazor.WebForm.Components.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Blazor.WebForm.Components.pfx</AssemblyOriginatorKeyFile>
<Version>1.1.9.1</Version>
<Version>1.1.9.2</Version>
<RootNamespace>asp</RootNamespace>
<Copyright>Jurio li</Copyright>
<AssemblyName>Blazor.WebForm.Components</AssemblyName>
Expand All @@ -17,7 +17,7 @@

<ItemGroup>
<PackageReference Include="Applied" Version="1.2.1.5" />
<PackageReference Include="Blazor.WebForm.UI" Version="1.1.9.1" />
<PackageReference Include="Blazor.WebForm.UI" Version="1.1.9.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.8" />
</ItemGroup>

Expand Down
16 changes: 15 additions & 1 deletion Blazor.WebForm.Components/Inner/Common/EditItemTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Blazor.WebForm.UI.PropertyComponents;
using Blazor.WebForm.UI;
using Blazor.WebForm.UI.PropertyComponents;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -8,13 +9,26 @@
namespace Microsoft.AspNetCore.Components
{
public partial class EditItemTemplate<TItem> : BindableTemplatePropertyComponent<object, TItem>, ICommonPropertyComponent
where TItem : class, new()
{
[Parameter]
public bool SubstituteItem { get; set; } = true;

protected override string PropertyName
{
get
{
return nameof(EditItemTemplate<TItem>);
}
}

protected override KeyValuePair<string, object>? OnConvertParameter(KeyValuePair<string, object> parameter)
{
if (parameter.Key == nameof(this.ChildContent) && this.SubstituteItem)
{
return new KeyValuePair<string, object>(this.PropertyName, this.GetEditTemplateProperty(this.ChildContent));
}
return base.OnConvertParameter(parameter);
}
}
}

0 comments on commit ef8013f

Please sign in to comment.