use

fun <T : Any, R> use(cls: KClass<T>, block: T.() -> R?): R?

Get a service for the given cls, and when it is present run the block on it.

When the service is not present null is returned. Otherwise the result of the block is returned.