Castle Windsor: Register class with internal constructor?

后端 未结 3 496
慢半拍i
慢半拍i 2021-01-21 05:20

A Castle Windsor question: Is it possible to register a class that has an internal constructor with the container?

Thanks Joni

3条回答
  •  旧巷少年郎
    2021-01-21 06:17

    It is easier to avoid the issue by having the class be internal and its constructor public, then you can register it with IncludeNonPublicTypes().

    // All other classes
    Classes.FromThisAssembly()
    .IncludeNonPublicTypes()  // Internal types
    .Where(x => !x.IsAbstract)
    .Configure(x => x.Named(Guid.NewGuid().ToString()))
    

提交回复
热议问题