Castle IOC container Practice startable Facility (I.)

Source: Internet
Author: User

Main content

1. Startable Facility Overview

2. Implement Istartable interface using the detailed

3. Do not implement Istartable interface use

A Startable Facility Overview

Before we start using startable facility, let's take a look at what it does, which allows a component to start or stop automatically after it satisfies a dependency. Information on the startable facility provided in the official website:

Facility Information
Uses Proxy No
Requires Configuration No
Uses Attributes No
Version Beta 2

Two Implement Istartable interface using the detailed

The use of startable facility can be said to be very simple, as long as our components implement the Istartable interface. Now we also have a program class that specifically controls server startup and stop, and we want the server to start automatically when its dependencies are met. Quite simply, we let the program class implement the Istartable interface:

/**//// <summary>
/// Author:Terrylee
/// Date:2006年4月28日
/// From:
/// </summary>
public class Program : IStartable
{
  private Server _server;
  public Program(Server server)
  {
    this._server = server;
  }
  public void Start()
  {
    _server.Start();
  }
  public void Stop()
  {
    _server.Stop();
  }
}

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.