Service: service layer analysis outline

Source: Internet
Author: User
Tags sharpdevelop
Usage of service in sharpdevelop:Some static auxiliary classes are required to help the main process complete some small and trivial functions that are additionally extended, such as The openfile function, such as obtaining the compiler output location. In the past, sharpdevelop used a class containing only static members, but later found that more than 10 static classes need to be defined, which is difficult to maintain and difficult to replace and expand. Now version 0.92 uses servicemanager to access these auxiliary functions.

The service structure is in core/service:
1. iservice interface:

Note that sharpdevelop initializes in the initializeservice () method, instead of in the constructor. This is because some services work before initialization. Therefore, the core is loaded first and then the base is loaded. In their respective initialize () methods, isinitialized must be judged before execution.

2. abstractservice, which is an abstract Implementation of iservice, skipped.

3. servicemanager:

Take a closer look at the getservice () method and find that this is a registration factory. Public iservice getservice (type servicetype)
{
Iservice S = (iservice) serviceshashtable [servicetype];
If (s! = NULL)
{
Return S;
}

Foreach (iservice service in servicelist)
{
If (servicetype. isinstanceoftype (Service ))
{
Serviceshashtable [servicetype] = service;
Return service;
}
}

Return NULL;
}

The service is stored in arraylist and hashtable in parallel. When the getservice () method is executed, it is first searched in hashtable. If it cannot be found, it is found that hashtable is inserted before the returned value, which improves the query speed.

Note that hashtable is only used in this method.

The initializeservicessubsystem () method is used in the main () function to add four core services and 11 base services, and initialize each Service (call the initializeservice () method of iservice ).

The unloadallservices () method is also used in the main () function to uninstall all services (call the iservice unloadservice () method ).

The core contains four services.
1. File: fileutilityservice. CS
It is used for common file operations and provides file icon operations.

2. Property
Access the sharpdevelop global Attribute Service.

3. Resource
Localization manager.

4. stringparser
The service that defines the attribute in the string.

The service in base is defined in sharpdevelop. addin: lines 32-55, a total of 11. Note that the path is "/workspace/services"

<Extension path = "/workspace/services">
<Class id = "projectservice"
Class = "icsharpcode. sharpdevelop. Services. defaultprojectservice"/>
<Class id = "fileservice"
Class = "icsharpcode. sharpdevelop. Services. defaultfileservice"/>
<Class id = "parserservice"
Class = "icsharpcode. sharpdevelop. Services. defaultparserservice"/>
<Class id = "taskservice"
Class = "icsharpcode. sharpdevelop. Services. taskservice"/>
<Class id = "statusbarservice"
Class = "icsharpcode. sharpdevelop. Services. defaultstatusbarservice"/>
<Class id = "toolbarservice"
Class = "icsharpcode. sharpdevelop. Services. toolbarservice"/>
<Class id = "languageservice"
Class = "icsharpcode. sharpdevelop. Services. languageservice"/>
<Class id = "classbrowsericonsservice"
Class = "icsharpcode. sharpdevelop. Services. classbrowsericonsservice"/>
<Class id = "languagebindingservice"
Class = "icsharpcode. sharpdevelop. Services. shareagebindingservice"/>
<Class id = "displaybindingservice"
Class = "icsharpcode. sharpdevelop. Services. displaybindingservice"/>
<Class id = "ambienceservice"
Class = "icsharpcode. sharpdevelop. Services. ambienceservice"/>
</Extension>

Each service in base has an interface and an abstract class.

Next, analyze all 15 services.

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.