Skip to content

Instantly share code, notes, and snippets.

@DavidSSL
Created September 21, 2012 19:44
Show Gist options
  • Save DavidSSL/3763470 to your computer and use it in GitHub Desktop.
Save DavidSSL/3763470 to your computer and use it in GitHub Desktop.
public static void Main()
{
// 1. Instantiate the IWindsor container object
var container = new WindsorContainer();
// 2. Register the services and the respective components that implement them
container.Register(
Component.For( typeof( IHtmlTitleRetriever ) ).ImplementedBy( typeof(HtmlTitleRetriever) ) ,
Component.For( typeof( IFileDownloader ) ).ImplementedBy( typeof( HttpFileDownloader ) ),
Component.For( typeof( ITitleScraper ) ).ImplementedBy( typeof( StringParsingTitleScraper ) )
);
// 3. "Resolve" the root service
var retriever = container.Resolve<IHtmlTitleRetriever>();
// 4. "Execute" the actual code to do the work
Console.WriteLine(retriever.GetTitle(new Uri(ConfigurationManager.AppSettings["fileUri"])));
Console.Read();
// 5. Release the container
container.Dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment