Build a plug-in Application Framework (IV)-service container

Source: Internet
Author: User
The iapplication interface is derived from the iservicecontainer interface. Why is it derived from iservicecontainer? Let's take a look at the definition of iservicecontainer. There are several addservice methods, removeservice methods, and getservice methods inherited from iserviceprovider. The Service itself is the basis of the. NET architecture during design. The Service provides a method to access a certain function during design, which is really easy to say. In my opinion, the essence of the servicecontainer mechanism is decoupling, that is, to strip the features of a type from the type itself. If You encapsulate the design-time functions of a type into a type, such a type contains many functions that are used only by developers and are not required by end users, this makes the type both bloated and not easy to expand. The design-time function is stripped out so that the type does not depend on the specific design environment. The reason is that there are so many unofficial. Net Design environments.

Our plug-in applicationsProgramThe framework also needs such a loose architecture, so I will apply it to our framework.

Servicecontainer is the implementation of iservicecontainer provided by. net. If there is no special need, we do not need to extend it, but use it directly. In the previous articleArticleServicecontainer that we use directly when implementing the iapplication interface. When using the service architecture, we always tend to have a root container. Each Service container forms a service container tree, and each node's service can be passed up until the root, when each node requests a service, we can always get it from the root node. I think of this root node as a service center, which summarizes all the services that can be provided. When an object wants to request a service (getservice), it only needs to send the service to the root node, the root node can pass the service object to it.

from another perspective, servicecontainer provides powerful support for our plug-ins as applications. By using servicecontainer, you can not only obtain all the functions provided by applications, in addition, you can add a service to the application through the plug-in, and the service you add can serve another service, so that our application framework is more flexible. However, everything has two sides. It brings flexibility and increases the complexity of developers' work. Therefore, applications developed using servciecontianer must provide sufficient detailed documents, otherwise, developers may not know how many services you can use, because many services are provided by plug-ins, maybe the author of the application does not know how many services will appear after the program is released.

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.