Skip to content

Commit

Permalink
1.1.8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurioli committed Aug 19, 2021
1 parent 1d7b956 commit 6f984bd
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 37 deletions.
Binary file removed Blazor.WebForm.Components.1.1.8.4.nupkg
Binary file not shown.
Binary file added Blazor.WebForm.Components.1.1.8.5.nupkg
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ protected override void OnInitialized()
}
}

protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
{
base.SetInnerPropertyWithInner(parameters, ref hasInnerContent);
base.SetInnerPropertyWithInner(parameters);
if (!parameters.ContainsKey(nameof(this.ID)) && string.IsNullOrEmpty(this.ID))
{
this.ID = Guid.NewGuid().ToString("N");
Expand Down
44 changes: 26 additions & 18 deletions Blazor.WebForm.Components/Base/ControlComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class ControlComponentBase<TControl> : ControlComponent<TControl
private IReadOnlyDictionary<string, object> _parameters;
private bool _renderedWithCascading;
private bool _renderedWithInner;
private bool _hasRenderedChildContent;
private TemplateControl _templateControl;

//new public virtual TControl Control
//{
Expand Down Expand Up @@ -226,6 +226,18 @@ EventHandlerDictionary IParameterViewComponent.Events

List<string> IControlParameterViewComponent.ReserveParameters { get; set; }

public TemplateControl TemplateControl
{
get
{
if (_templateControl == null)
{
_templateControl = (this.Control as IVirtualNamingContainer).TemplateControl;
}
return _templateControl;
}
}

//public void DataBind()
//{
// this.Control.DataBind();
Expand Down Expand Up @@ -321,10 +333,6 @@ protected RenderFragment RenderWithCascading<TValue>(TValue control, RenderFragm
if (!_renderedWithCascading)
{
_renderedWithCascading = true;
if (childContent != null && childLevel == 0)
{
_hasRenderedChildContent = true;
}
return RenderUtility.RenderWithCascading(control, childContent, childLevel, this.RenderWithCascading);
}
else
Expand All @@ -333,7 +341,7 @@ protected RenderFragment RenderWithCascading<TValue>(TValue control, RenderFragm
}
}

protected virtual void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
protected virtual void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
{

}
Expand All @@ -343,39 +351,39 @@ protected RenderFragment RenderWithInner<TValue>(TValue control) where TValue :
if (!_renderedWithInner)
{
_renderedWithInner = true;
bool hasInnerContent = false;
this.SetInnerPropertyWithInner(_parameters, ref hasInnerContent);
if (hasInnerContent)
{
_hasRenderedChildContent = true;
}
this.SetInnerPropertyWithInner(_parameters);
}
return this.Render(control);
}

protected override void OnUpdate(object sender, EventArgs e)
{
base.OnUpdate(sender, e);
this.SendMessage("RequestRefresh");
this.SendMessage("RequestRefresh", this.TemplateControl);
}

[MessageNotifyMethod]
protected void RequestRefresh()
protected void RequestRefresh(TemplateControl control)
{
if (!_hasRenderedChildContent)
if (control != this.TemplateControl)
{
this.StateHasChanged();
return;
}
this.StateHasChanged();
}

protected virtual void OnSubmit(object sender, EventArgs e)
{
this.SendMessage("RequestLoadPostData");
this.SendMessage("RequestLoadPostData", this.TemplateControl);
}

[MessageNotifyMethod]
protected void RequestLoadPostData()
protected void RequestLoadPostData(TemplateControl control)
{
if (control != this.TemplateControl)
{
return;
}
if (this.Control is IPostBackDataHandler)
{
this.LoadPostData(false);
Expand Down
5 changes: 3 additions & 2 deletions Blazor.WebForm.Components/Base/ControlComponentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ namespace Microsoft.AspNetCore.Components
{
public static class ControlComponentExtensions
{
public static void RequestRefresh<T>(this ControlComponent<T> component) where T : Control, new()
public static void RequestRefresh<T>(this TemplateControlComponent<T> component) where T : TemplateControl, new()
{
component.LoadPostData();
ControlComponentReflection<T>.SendMessageExtensionMethod(component, "RequestRefresh");
ControlComponentReflection<T>.SendMessageExtensionMethod(component, "RequestRefresh"
, arguments: new object[] { component.Control });
}
private class ControlComponentReflection<T> where T : Control, new()
{
Expand Down
3 changes: 1 addition & 2 deletions Blazor.WebForm.Components/Base/LabelControlComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ public string Text
}
}

protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
{
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
{
hasInnerContent = true;
this.Text = RenderUtility.GetContentString(this.ChildContent);
}
}
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.8.4</Version>
<Version>1.1.8.5</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.8.4" />
<PackageReference Include="Blazor.WebForm.UI" Version="1.1.8.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.8" />
</ItemGroup>

Expand Down
3 changes: 1 addition & 2 deletions Blazor.WebForm.Components/Button.razor
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,10 @@
_command.Invoke(sender, e);
}

protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
{
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
{
hasInnerContent = true;
this.Text = RenderUtility.GetContentString(this.ChildContent);
}
}
Expand Down
3 changes: 1 addition & 2 deletions Blazor.WebForm.Components/CheckBox.razor
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,10 @@
this.InvokePropertyBindEvent(nameof(this.Checked), this.Checked);
}

protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
{
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
{
hasInnerContent = true;
this.Text = RenderUtility.GetContentString(this.ChildContent);
}
}
Expand Down
3 changes: 1 addition & 2 deletions Blazor.WebForm.Components/HyperLink.razor
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@
}
}

protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
{
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
{
hasInnerContent = true;
this.Text = RenderUtility.GetContentString(this.ChildContent);
}
}
Expand Down
3 changes: 1 addition & 2 deletions Blazor.WebForm.Components/LinkButton.razor
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,10 @@
_command.Invoke(sender, e);
}

protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
{
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
{
hasInnerContent = true;
this.Text = RenderUtility.GetContentString(this.ChildContent);
}
}
Expand Down
3 changes: 1 addition & 2 deletions Blazor.WebForm.Components/RadioButton.razor
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@
this.InvokePropertyBindEvent(nameof(this.Checked), this.Checked);
}

protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
{
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
{
hasInnerContent = true;
this.Text = RenderUtility.GetContentString(this.ChildContent);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Blazor.WebForm.Components/ValidationSummary.razor
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
}
}

protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
{
if (!parameters.ContainsKey(nameof(this.ID)) && string.IsNullOrEmpty(this.ID))
{
Expand Down

0 comments on commit 6f984bd

Please sign in to comment.