Skip to content

Commit

Permalink
SrkToolkit.Web: compile SrkViewExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrock committed Mar 27, 2023
1 parent 121216a commit bc0cc2c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion Sources/SrkToolkit.Web.AspNetCore2/Models/TempMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace SrkToolkit.Web.Models
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// A message to display at the next loaded web page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<LangVersion>default</LangVersion>
<RootNamespace>SrkToolkit.Web</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.0.145-preview1</Version>
<Version>2.0.146-preview1</Version>
<Authors>SandRock</Authors>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Description>SrkToolkit.Web.AspNetCore2 is a bunch of extensions and components to use with your ASP MVC Core project.</Description>
Expand Down Expand Up @@ -37,8 +37,6 @@
<None Include="..\SrkToolkit.snk">
<Link>SrkToolkit.snk</Link>
</None>
<Compile Remove="SrkViewExtensions.cs" />
<None Include="SrkViewExtensions.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 7 additions & 5 deletions Sources/SrkToolkit.Web.AspNetCore2/SrkViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

namespace SrkToolkit.Web
{
using Microsoft.AspNetCore.Mvc.Razor;
using SrkToolkit.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/// <summary>
/// Extension methods for <see cref="WebViewPage"/>.
/// Extension methods for <see cref="IRazorPage"/>.
/// </summary>
public static class SrkViewExtensions
{
Expand All @@ -32,12 +33,13 @@ public static class SrkViewExtensions
/// </summary>
/// <param name="view"></param>
/// <returns></returns>
public static IList<TempMessage> TempMessages(this WebViewPage view)
public static IList<TempMessage> TempMessages(this IRazorPage view)
{
if (view.TempData == null)
return new List<TempMessage>();
if (view == null)
throw new ArgumentNullException(nameof(view));

var list = view.TempData[TempMessage.TempDataKey] as IList<TempMessage>;
var data = view.ViewContext.TempData;
var list = data[TempMessage.TempDataKey] as IList<TempMessage>;
return list ?? new List<TempMessage>();
}
}
Expand Down

0 comments on commit bc0cc2c

Please sign in to comment.