Castle Windsor passing constructor parameters

前端 未结 1 1300
终归单人心
终归单人心 2020-12-05 15:24

I have an IAddress class with a few properties. I then have a concrete type that implements this interface. This concrete type has a couple of different constructors I cou

相关标签:
1条回答
  • 2020-12-05 15:39

    You can use Resolve(object argumentsAsAnonymousType) or Resolve(IDictionary arguments). Windsor will select the best matching constructor.

    For example this will select your second constructor:

    container.Resolve<IAddress>(
        new {address1 = "myaddress1", address2 = "myaddress2", zipcode = "myzipcode"}
    )
    
    0 讨论(0)
提交回复
热议问题