I found the YouTube videos that Warren did (Part01 and Part02 in the Other section) really useful for doing this for a package. I think it's simpler if you are just doing it for a website, as you can update Startup.cs directly.
You can also see an example in the Our.Umbraco.GraphQL package's composer. Take a look at the first few lines of the Compose method to see it registering some singletons, for example.
Umbraco 9 Dependency Injection
Hi All,
I am just getting started with Umbraco 9. Has anyone got any example code and documentation to get up and running with dependency injection.
I want to inject my own helpers and services in a similar way to like we did with Umbraco 8 Composers and Components.
I didn't manage to figure it out yet for V9
Kind Regards
David
I found the YouTube videos that Warren did (Part01 and Part02 in the Other section) really useful for doing this for a package. I think it's simpler if you are just doing it for a website, as you can update Startup.cs directly.
You can also see an example in the Our.Umbraco.GraphQL package's composer. Take a look at the first few lines of the Compose method to see it registering some singletons, for example.
https://github.com/umbraco-community/umbraco-graphql/blob/v9/dev/src/Our.Umbraco.GraphQL/Compose/GraphQLComposer.cs
is working on a reply...