C# 具有构造函数参数的类是否可以进行Windsor构造函数注入?

C# 具有构造函数参数的类是否可以进行Windsor构造函数注入?,c#,dependency-injection,castle-windsor,constructor-injection,C#,Dependency Injection,Castle Windsor,Constructor Injection,看一看,这显示了如何添加非服务的依赖项(因此无法由容器解决)您知道在调用WindsorInstaller时使用哪种类型作为参数吗?我知道类型,但问题是,他们的WindsorInstaller实际上是在一个单独的项目中,它是作为一个NuGet包构建的,并由使用SomethingElse的项目订阅。谢谢,这是非常好的信息。但是,在我的例子中,组件及其注册包含在NuGet包中。在我的消费项目中,是否可以重新注册提供动态参数的组件?刚刚意识到我可以在消费项目中显式地执行注册,所以现在解决了这个问题。 p

看一看,这显示了如何添加非服务的依赖项(因此无法由容器解决)

您知道在调用
WindsorInstaller
时使用哪种类型作为参数吗?我知道类型,但问题是,他们的WindsorInstaller实际上是在一个单独的项目中,它是作为一个NuGet包构建的,并由使用SomethingElse的项目订阅。谢谢,这是非常好的信息。但是,在我的例子中,组件及其注册包含在NuGet包中。在我的消费项目中,是否可以重新注册提供动态参数的组件?刚刚意识到我可以在消费项目中显式地执行注册,所以现在解决了这个问题。
public interface ISomething
{
    string SomeMethod(string arg);
}


public class Something : ISomething
{
    public Something(Type type)
    {
        // initialization using type argument
    }

    public Something(string name)
    {
        // initialization using name argument
    }

    public string SomeMethod(string arg)
    {   
        // do something
    }
}       


public class SomethingElse : ISomethingElse
{
    public SomethingElse(ISomething something)
    {
        // ....
    }
}         


public class WindsorInstaller : IWindsorInstaller
{
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container.Register(Component.For<ISomething>().ImplementedBy<Something>().Named("Something").LifestyleSingleton());
    }
}
Castle.MicroKernel.Handlers.HandlerException was unhandled by user code
  HelpLink=groups.google.com/group/castle-project-users
  HResult=-2146233088
  Message=Can't create component 'Something' as it has dependencies to be satisfied.

'Something' is waiting for the following dependencies:
- Service 'System.Type' which was not registered.
- Parameter 'name' which was not provided. Did you forget to set the dependency?