Dnn.Platform icon indicating copy to clipboard operation
Dnn.Platform copied to clipboard

Add Dependency Injection support in Skin

Open tvatavuk opened this issue 3 years ago • 2 comments

Description of problem

In DNN skin ascx code developer need clean and simple way to get services registered with DNN9 DI.

Description of solution

Expected solution will be expanding DotNetNuke.UI.Skins.Skin with DependencyProvider property.

Description of alternatives considered

<%@ Control Language="vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %>
<%
    Dim messageService As IMessageService = Globals.DependencyProvider.GetService(Of IMessageService)()
    Dim message As String = messageService.GetMessage()
%>
<%= message %>

Screenshots

image

Additional context

  • https://github.com/dnnsoftware/Dnn.Platform/issues/2794
  • https://github.com/dnnsoftware/Dnn.Platform/issues/4954

tvatavuk avatar Dec 08 '21 20:12 tvatavuk

In 2sxc documentation is example how to use DNN DI in skin. Thx @iJungleboy 👍

How Can I Use Dependency Injection in Dnn Skins/Themes?

using DotNetNuke.Common.Extensions;
using System;
using Microsoft.Extensions.DependencyInjection;
using ToSic.Sxc.Services;

var sp = HttpContext.Current.GetScope().ServiceProvider;
var jsonSvc = sp.GetService<IJsonService>();
var json = jsonSvc.ToJson(someObject);

tvatavuk avatar Feb 09 '22 07:02 tvatavuk

We have detected this issue has not had any activity during the last 90 days. That could mean this issue is no longer relevant and/or nobody has found the necessary time to address the issue. We are trying to keep the list of open issues limited to those issues that are relevant to the majority and to close the ones that have become 'stale' (inactive). If no further activity is detected within the next 14 days, the issue will be closed automatically. If new comments are are posted and/or a solution (pull request) is submitted for review that references this issue, the issue will not be closed. Closed issues can be reopened at any time in the future. Please remember those participating in this open source project are volunteers trying to help others and creating a better DNN Platform for all. Thank you for your continued involvement and contributions!

stale[bot] avatar Jul 31 '22 03:07 stale[bot]

This issue has been closed automatically due to inactivity (as mentioned 14 days ago). Feel free to re-open the issue if you believe it is still relevant.

stale[bot] avatar Nov 02 '22 03:11 stale[bot]