Second, the main program is in the course of the university course, I always don't know how to simulate it until now. I always feel that the circuit map is very strange, I will always ask "What is the use of this circuit", "why there will be such an effect." In my mind, each part of the circuit should have a certain amount, but I always don't understand. My mother said, my idea is too long to be cured by the software. The circuit diagram should not always look at the module. The correct way should be a pole from the power supply, and I have been seeing the power supply. pole. I still don't understand the circuit diagram, but I don't think that the analysis source code will be more likely to be clearly analyzed in this kind of thinking. In the code of SharpDevelop, many code will suddenly lose the line of the function / method calls in seeing a certain place because many interfaces and plugins. For example, when you see an implementation of a function, you will jump into an interface, that is because this part of the function will perform a specific implementation of the object to implement this interface. From this perspective, the design pattern also brought a little difficulty for our research code. This problem is often encountered when watching Linux's next source code, and the method of looking for code clues is to search for related keywords with a text search tool. Under Linux I often use grep, Windows Like UltraEdit "Batch File Find" features (or "Search and Replace" tools). This is a little less experience in my code. If you know a better way, please tell me what I will learn. I don't want the post-pass code for the big segment to take place (space, bandwidth, and everyone's attention), in need, I will put the main code, so it is best to find the code to see. Pack the code, I solve it to "f: / sharpdevelop" (if not explained, the following is the root directory of this code). Since SharpDevelop itself is not very convenient to view the code, there is no "Go to Definition", so I suggest you turn its code to VS project. But a pity, SharpDevelop's project export function now has problems, if the total composite project of Src/sharpDevelop.cmbx will fail (I remember that the RC1 version can be successful, I don't know why the later version will come out) Therefore, it can only be exported by one project. Ok, let's take a look at SharpDevelop's code. 1. The starting point in the starting point of the main program is in /src/main/startup/sharpdevelopMain.cs, finding the main function This is the starting point for the entire program. The beginning is the display cover form and add command line control, where splashscreenform defines in the /src/main/gui/dialogs/splashscreen.cs file, this part I will not say much. Afterward
Application.ThreadException
=
New
ThreadExceptionEventhandler (showerrorbox);
SharpDevelop is an abnormal control in order to effectively report. When the system has an abnormal, SharpDevelop will intercept to pop up its own exception prompt report dialog. This code is implemented in this line. This method of showerrorbox is in class SharpDevelopMain, ExceptionBox defines in /src/main/startup/dialogs/exceptionbox.cs. If you need your own exception control, you can learn the skills here.
2, full of mystery initialization
String
[] AddIndirs
=
Icsharpcode.sharpDevelop.addinsettingshandler.GetaddIndirectories
OUT
IgnoreDefaultPath; AddINTreSingleton.SetaddIndirector (AddIndiRECTORIES);
Get the directory of the plugin through the AddInSettingShandler and inform AddInTreSingleton. AddInSettingShandler defines in /src/main/startup/dialogs/addintreesettingshandler.cs, which determines the directory location of the plugin by reading the Path property of the AddIndirectory node in the app.config file, or you can define your own AddIndirectories section to specify the plugin directory. If you don't do these configurations, the default directory is running in the SharpDevelop runs the directory.
ServiceManager.Services.AddService
New
MessageService ()); ServiceManager.Services.AddService
New
ResourceService (); serviceManager.services.addservice
New
IconService ());
Add three system default services, messaging services, resource services, and icon services through the ServiceManager (Service Manager). Among these three services, the message service is a variety of information prompts, and the other two are resources that belong to the system, and SharpDevelop is unified and managed by service. ServiceManager.Services.initializeServicesSystem ("/ Workspace / Services"); initialize other services. SharpDevelop Defines the service in the plug-in tree / Workspace / Services path, all the plugins under this path are considered to be a service, so if you define a service, you need to hang this path (here is the system The extension point of the service is. Pay attention! In this step, it quietly made an important initialization work under our eyelids. If you look at the official, ServiceManager is defined in the / src / main / core / service / serviceManager.cs file, and we find this line.
AddServices ((iService [])
AddintReeSingleton.addintree.gettreenode (ServiceSpath) .buildchildItems (this) .toArray (Iserve)));
Here, AddINtreSingleton first calls an instance of the Addintree (plug-in tree). According to the Singleton mode, the instance is initialized when the first call is called, and this is also true. The ADDINTREE of the entire system is initialized in this step. We will introduce the initialization of addintree in detail, and then look at the initialization of the service. In the serviceManager's InitialIzeServicesUBSystem method, all configurations under the service plugin path are retrieved by addINtree, and the specific object is read, and then the specific object is created. After one cycle, the InitializeService method initialization service is initialized by calling each service. AddIntree's initialization work container We will look at it later, first take the code's code.
Commands = addintreesingleton.addintree.gettreenode ("/ Workspace / AutoStart"). BuildChildItems (NULL); for (int i = 0; i / Workspace / Autostart is an extension path for the system automatically run commands, defining a plugin in this path automatically runs when the system is started. Here, the Command (command) under this path is established by the plug-in tree, and is executed one by one. The functionality of the buildchildItems method is to create a list of Command under this extension. I will specifically explain its implementation when introducing AddTree. At the end of the main program code, the initialization is turned off, close the cover form, and then perform the last command in the command list (that is, the main interface of the system). When exiting in the main interface, the system uninstalls all services. In this part of the code, we know the extension path / Workspace / Services and / Workspace / Autostart specified by the two systems. We can hang the two extension points when we implement the service and specify the system automatically run commands. . The blessing of the rejection, ServiceManager.Services can look for specific instances through the type (interface), which is the GetServices method. However, the specific implementation of ServiceManager We can take it later, it is no longer part of it. Next, let's take a look at the core -Addintree code of the entire plug-in system to see how it is initialized by plug-in configuration and establishes a plug-in tree backbone of the entire system.