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