mirror of https://github.com/abpframework/abp.git
7 changed files with 65 additions and 18 deletions
@ -1,18 +1,12 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Html; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets |
namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets |
||||
{ |
{ |
||||
public interface IWidgetRenderer : ITransientDependency |
public interface IWidgetRenderer : ITransientDependency |
||||
{ |
{ |
||||
Task<object> RenderAsync(string mywidget); |
Task<IHtmlContent> RenderAsync(IViewComponentHelper component, string mywidget); |
||||
} |
|
||||
|
|
||||
public class WidgetRenderer : IWidgetRenderer |
|
||||
{ |
|
||||
public Task<object> RenderAsync(string mywidget) |
|
||||
{ |
|
||||
throw new System.NotImplementedException(); |
|
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,27 @@ |
|||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Html; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets |
||||
|
{ |
||||
|
public class WidgetRenderer : IWidgetRenderer |
||||
|
{ |
||||
|
private readonly WidgetOptions _widgetOptions; |
||||
|
|
||||
|
public WidgetRenderer(IOptions<WidgetOptions> widgetOptions) |
||||
|
{ |
||||
|
_widgetOptions = widgetOptions.Value; |
||||
|
} |
||||
|
|
||||
|
public async Task<IHtmlContent> RenderAsync(IViewComponentHelper component, string mywidget) |
||||
|
{ |
||||
|
var componentType = _widgetOptions.Widgets.Single(w=>w.Name.Equals(mywidget)).ViewComponentType; |
||||
|
var args = new object(); |
||||
|
|
||||
|
return await component.InvokeAsync(componentType, args); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,6 @@ |
|||||
|
@page |
||||
|
@model DashboardDemo.Pages.widgets.MyWidgetViewComponentModel |
||||
|
@{ |
||||
|
} |
||||
|
|
||||
|
Hiiiiiii |
||||
@ -0,0 +1,13 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace DashboardDemo.Pages.widgets |
||||
|
{ |
||||
|
[ViewComponent] |
||||
|
public class MyWidgetViewComponentModel : ViewComponent |
||||
|
{ |
||||
|
public IViewComponentResult Invoke() |
||||
|
{ |
||||
|
return View("/Pages/widgets/MyWidgetViewComponent.cshtml", new MyWidgetViewComponentModel()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue