gpt4 book ai didi

c# - 哪个命名空间在 CaSTLe Windsor 中拥有 Component.For?

转载 作者:太空宇宙 更新时间:2023-11-03 23:34:44 26 4
gpt4 key购买 nike

我正在学习 CaSTLe Windsor 并找到了 this tutorial .其中,有这段代码:

private void button1_Click(object sender, EventArgs e)
{
// CREATE A WINDSOR CONTAINER OBJECT AND REGISTER THE INTERFACES, AND THEIR CONCRETE IMPLEMENTATIONS.
var container = new WindsorContainer();
container.Register(Component.For<Main>());
container.Register(Component.For<IDependency1>().ImplementedBy<Dependency1>());
container.Register(Component.For<IDependency2>().ImplementedBy<Dependency2>());

// CREATE THE MAIN OBJECT AND INVOKE ITS METHOD(S) AS DESIRED.
var mainThing = container.Resolve<Main>();
mainThing.DoSomething();
}

我正在跟进,但是 Component.For 调用为我抛出编译器错误。 Intellisense 找不到 Component。我应该为这个调用使用什么命名空间?

我通过 NuGet 添加了 CaSTLe.CoreCaSTLe.Windsor 引用。我一直在对象浏览器中搜索,试图找到 Component,但这是一个很常见的名称。本教程不方便地遗漏了* using,我找不到任何文档。

* 我发现很多教程和 StackOverflow 答案都遗漏了 using,我永远也弄不明白为什么。

最佳答案

它在 CaSTLe.MicroKernel.Registration 中。

这有时也让我很恼火,但如果项目是开源的,通常很容易搜索 their repository .

关于c# - 哪个命名空间在 CaSTLe Windsor 中拥有 Component.For?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30944262/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com