19

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.

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.

Could anyone help me with a sample project which includes a complete demonstration of registration/installation?

Thanks in advance :)

Ramesh Karna
  • 816
  • 1
  • 7
  • 24

3 Answers3

22

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.

They also have some good tutorials on code project, I used before:

UPDATE

Well, the most simplistic tutorial would be as follows:

1) In VS2010 create new console application

2) Right click on "References", select "Manage NuGet Packages", install Castle.Windsor

3) Use code below for 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!");
        }
    }
}
Sebastian K
  • 6,235
  • 1
  • 43
  • 67
  • Thanks for the book, i went through those tutorials but unfortunately unable to integrate these all concepts at a time. plz provide me a simple complete project :) – Ramesh Karna Feb 03 '13 at 03:59
  • Thanks a lot, it helps me a lot :), but i got some issues when i make some changes in it, please check the this link http://stackoverflow.com/questions/14669756/console-writeline-is-not-working-after-resolve – Ramesh Karna Feb 03 '13 at 05:26
1

If you are looking for a tutorial, check this link

It is explaining CastleWindsor, Nhibernate and UnitOfWork in one example.

Rakesh Burbure
  • 1,045
  • 12
  • 27
0

Also you can add Castle Windsor using

Tools --> NuGet Package Manager --> Package Manager Console.

And than just type 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.

Alexandr
  • 5,460
  • 4
  • 40
  • 70