Introduction. Windsor Container is an "Inversion of Control Container" which is part of the set of open source solutions with Castle Monorail niledutch tracking Project, Active Record and microkernel. But go to parties. Before I explain that is Windsor Container we should know that is the "Inversion of Control" (IoC). This is a concept little .NET widespread in the world, and even less used, mainly due to the high learning curve for use in a development. The basic idea of the IoC framework is to be the one who perform the invocation of objects made by programmers and not vice versa, which implies it is the framework that has control of the objects that are invoked and not us. Windsor Container is a container of objects using the IoC principle to create the objects of the classes and their dependencies. This reduces the coupling niledutch tracking of the system, facilitates the reuse of objects, testing and performing refactoring. How to use Windsor Container. Since making niledutch tracking contact with Windsor Container write a simple class, Adder class, which as the name suggests their objective is to add two numbers:
... Public static void Main (string [] args) {var adder = new Adder (); sumador.Suma var result = (1,1); ...} Using WC as the objects are in a container, niledutch tracking we should not instantiate objects but must ask for them to the container. First we build the container, this is created from an XML configuration file, which will be explained niledutch tracking below. Once our container has been created, we ask the container object of type Adder and finally use it.
... Public static WindsorContainer miContenedor; public static void Main (string niledutch tracking [] args) {// Create the container = new WindsorContainer miContenedor (new XmlInterpreter ("MiContenedor.xml")); // We call an object of type adder to adder var container = miContenedor.Resolve <Adder> (); sumador.Suma var result = (1,1); } ... As we see the container niledutch tracking must be a static variable to always use the same container throughout the lifecycle of apliciĆ³n. niledutch tracking It would not make sense to go created a container every time we have to create an object. The configuration file is an XML file WC in which all objects are included in the specified container. This file has the following format:
<Configuration> <components> <component id = "Adder" type = "IoC.Tutoriales.Part1.Sumador, IoC.Tutoriales.Part1" /> </ components> </ configuration> The objects to be included are specified by the tag " component "(included in components), each component must define a unique identifier (id) into the container and the class type of the object to which it belongs (type =" class name, name of the assembly "). niledutch tracking This configuration can be included in the App.config, but my advice is to be in a separate file, and that file windsor xml configuration are susceptible to be very large and are usually modifed. I hope you might help this little introduction to the world IoC in the following articles explain IoC most interesting things that insurance niledutch tracking will be more useful. The sample code in this tutorial is at this link.
Well, as you know, I have no idea these things programming, but I promise niledutch tracking to be true to your "Sesame Street programming" to learn even more than Don Pedro. I hope a speedy sequel. Greetings Delete Reply
2010 (1) May (1) 2009 (1) May (1) 2008 (3) January (1) September (1) August (1) Windsor Container Part. I
No comments:
Post a Comment