Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dependency Injection support in SkinObject #4954

Closed
5 tasks done
tvatavuk opened this issue Dec 8, 2021 · 4 comments
Closed
5 tasks done

Add Dependency Injection support in SkinObject #4954

tvatavuk opened this issue Dec 8, 2021 · 4 comments

Comments

@tvatavuk
Copy link

tvatavuk commented Dec 8, 2021

Description of problem

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

Description of solution

In DNN WebForms module we use ServiceProvider from PortalModuleBase.DependencyProvider.
Expected solution will be expanding SkinObjectBase with same DependencyProvider property.

Description of alternatives considered

Something simmilar to this ugly, hacky workaround :-(

IServiceProvider ServiceProvider => ((IServiceScope)HttpContextSource.Current.Items[typeof(IServiceScope)]).ServiceProvider;

Additional context

Developing code that use dependencies registered in DNN9 DI, but without DNN9 DI is not nice.
Expanding SkinObjectBase API with DependencyProvider looks as best solution/workaround in this moment, until constructor injection become reality.

Affected browser

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer
  • Edge
@tvatavuk
Copy link
Author

tvatavuk commented Feb 2, 2022

Thx @bdukes for showing me dnn DI extension methods that can simplify code above.

IServiceScope currentScope = HttpContext.Current.GetScope();
IServiceProvider serviceProvider = HttpContext.Current.GetScope().ServiceProvider;

@tvatavuk
Copy link
Author

tvatavuk commented Feb 9, 2022

@stale
Copy link

stale bot commented Jul 31, 2022

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 stale bot added the stale label Jul 31, 2022
@stale
Copy link

stale bot commented Nov 2, 2022

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 stale bot closed this as completed Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant