Register Plain C# Type
There are various ways to use Register. Let's take the following complex type as an example.
#
Register Concrete TypeIt can resolve like this:
#
Register as InterfaceIt can resolve like this:
#
Register as multiple InterfaceIt can resolve like this:
#
Register all implemented interfaces automaticallyIt can resolve like this:
#
Register all implemented interfaces and concrete typeIt can resolve like this:
#
Register lifecycle marker interfacesnote
This is similar to Register<GameController>(Lifetime.Singleton).AsImplementedInterfaces()
If you want to customize the exception handling for entry points, you can register a callback with the following.
If you have multiple EntryPoints, you have the option to use the following declaration as grouping.
This is the same as:
See the Plain C# Entry point section for more information.
#
Register instancenote
RegisterIntance
always has a Scoped
lifetime, so it has no arguments.
It can resolve like this:
#
Register instance as interfaceUse As*
declarations.
#
Register type-specific parametersIf the types are not unique, but you have a dependency you want to inject at startup, you can use the following:
Or, you can name a paramter with a key.
It can resolve like this:
This Register only works when being injected into SomeService
.