Add Element ActionResult

This commit is contained in:
Frank A. Krueger 2017-11-09 19:34:37 -08:00
parent 18ac283747
commit 5690adac90
7 changed files with 77 additions and 14 deletions

View File

@ -1,8 +0,0 @@
using System;
namespace Ooui.AspNetCore
{
public class Class1
{
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace Ooui.AspNetCore
{
public class ElementResult : ActionResult
{
public ElementResult (Element element)
{
}
public override async Task ExecuteResultAsync (ActionContext context)
{
var path = context.HttpContext.Request.Path;
var response = context.HttpContext.Response;
response.StatusCode = 200;
response.ContentType = "text/html";
var html = Encoding.UTF8.GetBytes (UI.RenderTemplate (path));
response.ContentLength = html.Length;
using (var s = response.Body) {
await s.WriteAsync (html, 0, html.Length).ConfigureAwait (false);
}
}
}
}

View File

@ -4,4 +4,10 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ooui\Ooui.csproj" />
</ItemGroup>
</Project>

View File

@ -13,6 +13,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ooui.Forms", "Ooui.Forms\Oo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ooui.AspNetCore", "Ooui.AspNetCore\Ooui.AspNetCore.csproj", "{2EDF0328-698B-458A-B10C-AB1B4786A6CA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PlatformSamples", "PlatformSamples", "{12ADF328-BBA8-48FC-9AF1-F11B7921D9EA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCoreMvc", "PlatformSamples\AspNetCoreMvc\AspNetCoreMvc.csproj", "{7C6D477C-3378-4A86-9C31-AAD51204120B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -86,6 +90,18 @@ Global
{2EDF0328-698B-458A-B10C-AB1B4786A6CA}.Release|x64.Build.0 = Release|Any CPU
{2EDF0328-698B-458A-B10C-AB1B4786A6CA}.Release|x86.ActiveCfg = Release|Any CPU
{2EDF0328-698B-458A-B10C-AB1B4786A6CA}.Release|x86.Build.0 = Release|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Debug|x64.ActiveCfg = Debug|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Debug|x64.Build.0 = Debug|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Debug|x86.ActiveCfg = Debug|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Debug|x86.Build.0 = Debug|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Release|Any CPU.Build.0 = Release|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Release|x64.ActiveCfg = Release|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Release|x64.Build.0 = Release|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Release|x86.ActiveCfg = Release|Any CPU
{7C6D477C-3378-4A86-9C31-AAD51204120B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
@ -96,5 +112,17 @@ Global
$1.TabsToSpaces = True
$0.CSharpFormattingPolicy = $2
$2.scope = text/x-csharp
$2.NewLinesForBracesInProperties = False
$2.NewLinesForBracesInAccessors = False
$2.NewLinesForBracesInAnonymousMethods = False
$2.NewLinesForBracesInControlBlocks = False
$2.NewLinesForBracesInAnonymousTypes = False
$2.NewLinesForBracesInObjectCollectionArrayInitializers = False
$2.NewLinesForBracesInLambdaExpressionBody = False
$2.SpacingAfterMethodDeclarationName = True
$2.SpaceAfterMethodCallName = True
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7C6D477C-3378-4A86-9C31-AAD51204120B} = {12ADF328-BBA8-48FC-9AF1-F11B7921D9EA}
EndGlobalSection
EndGlobal

View File

@ -295,11 +295,11 @@ namespace Ooui
}
response.Close ();
}
}
string RenderTemplate (string elementPath)
{
return Template.Replace ("@ElementPath", elementPath).Replace ("@Styles", rules.ToString ());
}
public static string RenderTemplate (string elementPath)
{
return Template.Replace ("@ElementPath", elementPath).Replace ("@Styles", rules.ToString ());
}
class DataHandler : RequestHandler

View File

@ -8,11 +8,15 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview2-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Ooui.AspNetCore\Ooui.AspNetCore.csproj" />
<ProjectReference Include="..\..\Ooui\Ooui.csproj" />
</ItemGroup>
</Project>

View File

@ -4,7 +4,10 @@ using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using AspNetCoreMvc.Models;
using Ooui;
using Ooui.AspNetCore;
namespace AspNetCoreMvc.Controllers
{
@ -12,7 +15,8 @@ namespace AspNetCoreMvc.Controllers
{
public IActionResult Index()
{
return View();
var button = new Button ();
return new ElementResult (button);
}
public IActionResult About()