I am completely new with IoC/windsor. I started with Google to learn it, but unfortunately, I haven't got proper documentation which could be easier for me to understand. so I came here with such this title/questions.
我对IoC / windsor来说是全新的。我从谷歌开始学习它,但不幸的是,我没有得到适当的文档,这对我来说更容易理解。所以我来到这里有这样的标题/问题。
Every document/pages(web), Starting something similar like this
每个文档/页面(网页),像这样开始类似的东西
"We should start from registering the class/interface then resolve it ... "
“我们应该从注册类/接口开始然后解决它......”
but none of the page shows complete documentation on how to achieve that, I tried to make a simple project too, but I failed to run it. I don't know how to resolve container , where/how to call for install(), I am totally messed up.
但是没有一个页面显示有关如何实现这一目标的完整文档,我也尝试制作一个简单的项目,但是我没能运行它。我不知道如何解决容器,在哪里/如何调用install(),我完全搞砸了。
Could anyone help me with a sample project which includes a complete demonstration of registration/installation?
有人可以帮我一个示例项目,其中包括完整的注册/安装演示吗?
Thanks in advance :)
提前致谢 :)
3 个解决方案
#1
16
Also Mark Seemann's Dependency Injection in .NET book is a good place to start. Well written and has a chapter on Castle Windsor specifically.
Mark Seemann的.NET依赖注入书也是一个很好的起点。写得很好,并专门有一章关于Castle Windsor。
They also have some good tutorials on code project, I used before:
他们还有一些关于代码项目的好教程,我之前使用过:
UPDATE
UPDATE
Well, the most simplistic tutorial would be as follows:
那么,最简单的教程如下:
1) In VS2010 create new console application
1)在VS2010中创建新的控制台应用程序
2) Right click on "References", select "Manage NuGet Packages", install Castle.Windsor
2)右键单击“References”,选择“Manage NuGet Packages”,安装Castle.Windsor
3) Use code below for Program.cs:
3)使用以下代码来编写Program.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
namespace ExploringCastleWindsor
{
internal class Program
{
interface ILogger
{
void Log(string message);
}
class Logger : ILogger
{
public void Log(string message)
{
Console.WriteLine(message);
}
}
static void Main(string[] args)
{
// Registering
var container = new WindsorContainer();
container.Register(Component.For<ILogger>().ImplementedBy<Logger>());
// Resolving
var logger = container.Resolve<ILogger>();
logger.Log("Hello World!");
}
}
}
#2
1
If you are looking for a tutorial, check this link
如果您正在寻找教程,请查看此链接
It is explaining CastleWindsor, Nhibernate and UnitOfWork in one example.
它在一个例子中解释了CastleWindsor,Nhibernate和UnitOfWork。
#3
0
Also you can add Castle Windsor using
您也可以添加Castle Windsor
Tools --> NuGet Package Manager --> Package Manager Console.
工具 - > NuGet包管理器 - >包管理器控制台。
And than just type Install-Package Castle.Windsor
而不仅仅是键入Install-Package Castle.Windsor
After you done with assamblies you are good to go with code. Sebastian K provided a good example of working code.
完成任务后,您可以使用代码。 Sebastian K提供了一个很好的代码工作示例。
#1
16
Also Mark Seemann's Dependency Injection in .NET book is a good place to start. Well written and has a chapter on Castle Windsor specifically.
Mark Seemann的.NET依赖注入书也是一个很好的起点。写得很好,并专门有一章关于Castle Windsor。
They also have some good tutorials on code project, I used before:
他们还有一些关于代码项目的好教程,我之前使用过:
UPDATE
UPDATE
Well, the most simplistic tutorial would be as follows:
那么,最简单的教程如下:
1) In VS2010 create new console application
1)在VS2010中创建新的控制台应用程序
2) Right click on "References", select "Manage NuGet Packages", install Castle.Windsor
2)右键单击“References”,选择“Manage NuGet Packages”,安装Castle.Windsor
3) Use code below for Program.cs:
3)使用以下代码来编写Program.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
namespace ExploringCastleWindsor
{
internal class Program
{
interface ILogger
{
void Log(string message);
}
class Logger : ILogger
{
public void Log(string message)
{
Console.WriteLine(message);
}
}
static void Main(string[] args)
{
// Registering
var container = new WindsorContainer();
container.Register(Component.For<ILogger>().ImplementedBy<Logger>());
// Resolving
var logger = container.Resolve<ILogger>();
logger.Log("Hello World!");
}
}
}
#2
1
If you are looking for a tutorial, check this link
如果您正在寻找教程,请查看此链接
It is explaining CastleWindsor, Nhibernate and UnitOfWork in one example.
它在一个例子中解释了CastleWindsor,Nhibernate和UnitOfWork。
#3
0
Also you can add Castle Windsor using
您也可以添加Castle Windsor
Tools --> NuGet Package Manager --> Package Manager Console.
工具 - > NuGet包管理器 - >包管理器控制台。
And than just type Install-Package Castle.Windsor
而不仅仅是键入Install-Package Castle.Windsor
After you done with assamblies you are good to go with code. Sebastian K provided a good example of working code.
完成任务后,您可以使用代码。 Sebastian K提供了一个很好的代码工作示例。