mirror of https://github.com/abpframework/abp.git
2 changed files with 77 additions and 8 deletions
@ -1,14 +1,73 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.FileProviders; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Widgets; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.Shared.Demos.ButtonsDemo |
|||
{ |
|||
[Widget] |
|||
public class ButtonsDemoViewComponent : AbpViewComponent |
|||
{ |
|||
public const string ViewPath = "/Views/Components/Themes/Shared/Demos/ButtonsDemo/Default.cshtml"; |
|||
|
|||
private const string DemoSectionOpeningTag = "<DemoSection:"; |
|||
private const string DemoSectionClosingTag = "</DemoSection:"; |
|||
|
|||
private readonly IVirtualFileProvider _virtualFileProvider; |
|||
|
|||
public ButtonsDemoViewComponent(IVirtualFileProvider virtualFileProvider) |
|||
{ |
|||
_virtualFileProvider = virtualFileProvider; |
|||
} |
|||
|
|||
public IViewComponentResult Invoke() |
|||
{ |
|||
return View("/Views/Components/Themes/Shared/Demos/ButtonsDemo/Default.cshtml"); |
|||
var model = new DemoViewModel(); |
|||
|
|||
var viewFileInfo = _virtualFileProvider.GetFileInfo(ViewPath); |
|||
var viewFileContent = viewFileInfo.ReadAsString(); |
|||
|
|||
var lines = viewFileContent.SplitToLines(); |
|||
|
|||
StringBuilder sb = null; |
|||
|
|||
foreach (var line in lines) |
|||
{ |
|||
if (line.Contains(DemoSectionOpeningTag)) |
|||
{ |
|||
sb = new StringBuilder(); |
|||
} |
|||
else if (line.Contains(DemoSectionClosingTag, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
var demoName = line.Substring(line.IndexOf(DemoSectionClosingTag, StringComparison.InvariantCultureIgnoreCase) + DemoSectionClosingTag.Length); |
|||
if (demoName.Contains(">")) |
|||
{ |
|||
demoName = demoName.Left(demoName.IndexOf(">", StringComparison.InvariantCultureIgnoreCase)); |
|||
} |
|||
|
|||
model.SourceCodes[demoName] = sb.ToString(); |
|||
sb = new StringBuilder(); |
|||
} |
|||
else if(sb != null) |
|||
{ |
|||
sb.AppendLine(line); |
|||
} |
|||
} |
|||
|
|||
return View(ViewPath, model); |
|||
} |
|||
} |
|||
|
|||
public class DemoViewModel |
|||
{ |
|||
public Dictionary<string, string> SourceCodes { get; set; } |
|||
|
|||
public DemoViewModel() |
|||
{ |
|||
SourceCodes = new Dictionary<string, string>(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,7 +1,17 @@ |
|||
<h2> |
|||
Basic Buttons |
|||
</h2> |
|||
<div> |
|||
<abp-button button-type="Primary" text="Primary button" /> |
|||
<abp-button button-type="Secondary" text="Secondary button" /> |
|||
@model Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.Shared.Demos.ButtonsDemo.DemoViewModel |
|||
<div class="abp-theme-demo-section"> |
|||
<h2> |
|||
Basic Buttons |
|||
</h2> |
|||
<div class="abp-theme-demo-section-body"> |
|||
<!-- <DemoSection:Buttons.Basic> --> |
|||
<abp-button button-type="Primary" text="Primary button" /> |
|||
<abp-button button-type="Secondary" text="Secondary button" /> |
|||
<!-- </DemoSection:Buttons.Basic> --> |
|||
</div> |
|||
<div> |
|||
<pre> |
|||
@Model.SourceCodes["Buttons.Basic"] |
|||
</pre> |
|||
</div> |
|||
</div> |
|||
Loading…
Reference in new issue