Castle IOC container Practice typedfactory Facility (I.)

Source: Internet
Author: User

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");
  }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.