Factory. Facility. So what is the Typed. Flagship ZDNet weblog, covering a broad range of technology news. Rfpmz8U/hqdefault.jpg' alt='Halo 2 Pc Part 1' title='Halo 2 Pc Part 1' />Factory. Facility To put it simply, it creates an abstract factory class for you to use in your code. The easiest place to start is looking at code, so what are we about to change. Open up te interfaces. IOCExample. public interface IStart. Page. Model. IHeading Heading get set. IHeading Sub. Heading get set. IHeading. string Caption get set. Value get set. IStart. Page. View. Model. IStart. Page. Model viewmodel get set. IStart. Page. Model Get. IShell. void Run. We are now going to add a new interface to this file which will define our first abstract factory. Add the following code to the bottom of the interfaces. IMy. First. Factory. T Createlt T. Releaseobject value. Notice that we are using a Generic create method in this example, this will become clearer later on. Now that we have the interface what do we do So, lets open up the installers. Add. Facilitylt Typed. Factory. Facility. Adding this code into the installer tells castle that we are about to specify a new type factory, we now just need to add a new line to identity thefactory as shown below. RegisterComponent. Forlt IMy. First. Factory. As. Factory. Your installer class should now look like this. Castle. Facilities. Typed. Factory. using Castle. Micro. Kernel. Registration. IOCExample. public class Installers IWindsor. Installer. public void InstallCastle. Windsor. IWindsor. Container container, Castle. Micro. Kernel. Sub. Systems. Configuration. IConfiguration. Store store. Add. Facilitylt Typed. Factory. Facility. RegisterComponent. Forlt IMy. First. Factory. As. Factory. RegisterComponent. Forlt IStart. Page. Model. Implemented. Bylt Start. Page. Model. Lifestyle. Transient. RegisterComponent. Forlt IStart. Page. View. Model. Implemented. Bylt Start. Page. View. Model. Lifestyle. Transient. RegisterComponent. Forlt IHeading. Implemented. Bylt Heading. Lifestyle. Transient. RegisterComponent. Forlt IShell. Implemented. Bylt Shell. Lifestyle. Transient. RegisterComponent. Forlt Main. Window. Lifestyle. Transient. Ive grouped the Typed. Facility. Factory and the interface registration together for clarity. Notice that when registering the IMy. First. Factory interface with castle that we have NOT provided a type that it will map to, this will be performed by castle for us. Now lets make a few modifications to the Main. Window. xaml. cs file so that we can consume the IMy. First. Factory interface. Main. WindowIMy. First. Factory context. Createlt IStart. Page. View. Model. Get. this. Data. Context obj. A Crack In The Wall Pullinger Art. Releaseobj. Changing the constructors Mandatory dependency to IMy. First. Factory will cause castle to create the abstract factory and pass that into the Main. Windows constructor for us. Notice that the this. Data. Context assignment has also changed, this now calls the Createlt T method on the IMy. First. Factory interface but passes in the name of the interface that we want to create. This will cause the abstract factory to create this type for us, as before, we call the Get method to return a valid View. Model populated with data which will be bound to the two textblocks in the Xaml code. Also notice that we call the context. Release method of the factory to allow the instance to be released and garbage collected. Well thats about it for this part of the tutorial, its pretty basic but gives you a little bit to work with. Download Example.