Skip to content

Instantly share code, notes, and snippets.

@skttl
Created December 6, 2019 06:51
Show Gist options
  • Save skttl/c6fd4e92f8a50f3cb4d6d464b97688e9 to your computer and use it in GitHub Desktop.
Save skttl/c6fd4e92f8a50f3cb4d6d464b97688e9 to your computer and use it in GitHub Desktop.
Inject UmbracoHelper in custom class v8
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