The Factorysupport of Castle IOC container practice facility

Source: Internet
Author: User
Tags instance method object model

It uses the following two processing strategies:

1. Using accessors to access instances of a component

2. To access an instance of a component using a static method or an instance method

Main content

1. Overview

2. Why need Factorysupport Facility

3. How to use

4. Examples of common configurations

5. Analysis of the principle of realization

A Overview

Factorysupport facility allows us to use an existing factory to create an instance of a component, adding an existing object model to the container so that it can use automatic assembly. It uses the following two processing strategies:

1. To access an instance of a component through an accessor

2. To access an instance of a component by means of a static method or instance

Two Why need Factorysupport Facility

To answer this question, let's look at a simple example of using a factory, as shown in the following code:

public interface IComponent
{
  void Display();
}
public class MyComponent : IComponent
{
  public MyComponent()
  { 
  }
  public void Display()
  {
    Console.WriteLine("MyComponent");
  }
}
public class MyFactory
{
  public MyFactory()
  {
  }
  public IComponent Create()
  {
    return new MyComponent();
  }
}

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.