Kodein. Using property name (KProperty) in my factory

27 views Asked by At

I want use information about property while creating instance. Example:

    @Test
    fun test() {
        val kodein = DI {
            bind<DataBasedPropertyName> {
                //What need here?
            }
        }
        val foo: DataBasedPropertyName by kodein.di.instance()
        assertEquals("foo", foo.str)
        val bar: DataBasedPropertyName by kodein.di.instance()
        assertEquals("bar", bar.str)
    }

    data class DataBasedPropertyName(val str: String) {

    }

E.g. foo must created with str='foo', bar with str='bar'. Is it possible?

0

There are 0 answers