From 5690adac90d1ff2065d1a6c76f1da6b3936539af Mon Sep 17 00:00:00 2001 From: "Frank A. Krueger" Date: Thu, 9 Nov 2017 19:34:37 -0800 Subject: [PATCH] Add Element ActionResult --- Ooui.AspNetCore/Class1.cs | 8 ----- Ooui.AspNetCore/ElementResult.cs | 29 +++++++++++++++++++ Ooui.AspNetCore/Ooui.AspNetCore.csproj | 6 ++++ Ooui.sln | 28 ++++++++++++++++++ Ooui/UI.cs | 8 ++--- .../AspNetCoreMvc/AspNetCoreMvc.csproj | 6 +++- .../Controllers/HomeController.cs | 6 +++- 7 files changed, 77 insertions(+), 14 deletions(-) delete mode 100644 Ooui.AspNetCore/Class1.cs create mode 100644 Ooui.AspNetCore/ElementResult.cs diff --git a/Ooui.AspNetCore/Class1.cs b/Ooui.AspNetCore/Class1.cs deleted file mode 100644 index 854abd3..0000000 --- a/Ooui.AspNetCore/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Ooui.AspNetCore -{ - public class Class1 - { - } -} diff --git a/Ooui.AspNetCore/ElementResult.cs b/Ooui.AspNetCore/ElementResult.cs new file mode 100644 index 0000000..19faf23 --- /dev/null +++ b/Ooui.AspNetCore/ElementResult.cs @@ -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); + } + } + } +} diff --git a/Ooui.AspNetCore/Ooui.AspNetCore.csproj b/Ooui.AspNetCore/Ooui.AspNetCore.csproj index 72764a6..372fb3c 100644 --- a/Ooui.AspNetCore/Ooui.AspNetCore.csproj +++ b/Ooui.AspNetCore/Ooui.AspNetCore.csproj @@ -4,4 +4,10 @@ netstandard2.0 + + + + + + diff --git a/Ooui.sln b/Ooui.sln index 4ebbadc..a5e7898 100644 --- a/Ooui.sln +++ b/Ooui.sln @@ -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 diff --git a/Ooui/UI.cs b/Ooui/UI.cs index 992480a..753639a 100644 --- a/Ooui/UI.cs +++ b/Ooui/UI.cs @@ -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 diff --git a/PlatformSamples/AspNetCoreMvc/AspNetCoreMvc.csproj b/PlatformSamples/AspNetCoreMvc/AspNetCoreMvc.csproj index 586eca9..af144cb 100644 --- a/PlatformSamples/AspNetCoreMvc/AspNetCoreMvc.csproj +++ b/PlatformSamples/AspNetCoreMvc/AspNetCoreMvc.csproj @@ -8,11 +8,15 @@ - + + + + + diff --git a/PlatformSamples/AspNetCoreMvc/Controllers/HomeController.cs b/PlatformSamples/AspNetCoreMvc/Controllers/HomeController.cs index 69606f5..10f2378 100644 --- a/PlatformSamples/AspNetCoreMvc/Controllers/HomeController.cs +++ b/PlatformSamples/AspNetCoreMvc/Controllers/HomeController.cs @@ -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()