Created
December 6, 2019 06:51
-
-
Save skttl/c6fd4e92f8a50f3cb4d6d464b97688e9 to your computer and use it in GitHub Desktop.
Inject UmbracoHelper in custom class v8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IMyService {} | |
public class MyClass : IMyService { | |
UmbracoHelper umbracoHelper; | |
public MyClass(UmbracoHelper umbracoHelper) | |
{ | |
this.umbracoHelper = umbracoHelper; | |
} | |
} | |
public class MyClassComposer : IUserComposer | |
{ | |
public void Compose(Composition composition) | |
{ | |
composition.Register<IMyService, MyClass>(Lifetime.Request); | |
} | |
} | |
// That will register your service with the LightInject DI container, and so it will | |
// automatically know to inject the UmbracoHelper class when your class is needed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment