Main content
1. Typedfactory Facility Overview
2. Typedfactory Facility Quick Start
A Typedfactory Facility Overview
I believe that the factory method design mode is no stranger, in factory methods, for each specific product needs to have a corresponding factory class, with the specific products more and more, we are more and more difficult to manage the factory class, So how do you manage the plant through the IOC container? This article will give you an answer. Before we start, let's take a look at the information on the Typedfactory facility that is available on the official website of Castle:
Facility Information
Uses Proxy Yes
Requires Configuration Yes
Uses attributes No
Version Beta 2
Two Typedfactory Facility Quick Start
1. Create a product interface
/**//// <summary>
/// Author:Terrylee
/// Date:2006年5月12日
/// From:http://terrylee.cnblogs.com
/// </summary>
public interface IProduct
{
void Display();
}
2. Define multiple specific products, implemented in interface IProduct
/**//// <summary>
/// Author:Terrylee
/// Date:2006年5月12日
/// From:http://terrylee.cnblogs.com
/// </summary>
public class ConcreteProductA : IProduct
{
public void Display()
{
Console.WriteLine("ConcreteProductA");
}
}
/**//// <summary>
/// Author:Terrylee
/// Date:2006年5月12日
/// From:http://terrylee.cnblogs.com
/// </summary>
public class ConcreteProductB : IProduct
{
public void Display()
{
Console.WriteLine("ConcreteProductB");
}
}
/**//// <summary>
/// Author:Terrylee
/// Date:2006年5月12日
/// From:http://terrylee.cnblogs.com
/// </summary>
public class ConcreteProductC : IProduct
{
public void Display()
{
Console.WriteLine("ConcreteProductC");
}
}