See:Fbt2008MasterpieceSharpdevelop source code analysis notes (1)
Source Document
InFbt2008As described in the masterpieceSharpdevelopItsRuntimeDuring the startup processGuiStart to add.
It is written to the following system:CodeStart part
System Code:
// This code isProgramThe front-end plug-in is loaded at startup, and/workspace/autostart is the extension path of the system's Automatic Running command. The plug-in defined in this path will automatically run at system startup. Here, the command (command) in this path is initialized through the plug-in tree and executed one by one. The buildchilditems method is used to create the command list under this extension point.
Commands = Addintreesingleton. addintree. gettreenode ( " /Workspace/autostart " ). Buildchilditems ( Null );
For ( Int I = 0 ; I < Commands. Count - 1 ; ++ I)
{
(Icommand) commands [I]). Run ();
}
}
This code will load the following configuration file, according toClassidLoad and run
One of the plug-ins (sharpdevelopcore. addin file)
Fragment
<Extension path ="/Workspace/autostart">
<Class id = "initializeworkbenchcommand"
Class ="Icsharpcode. sharpdevelop. commands. initializeworkbenchcommand"/>
<Class id = "startcodecompletionwizard"
Class = "icsharpcode. sharpdevelop. commands. startcodecompletionwizard"/>
<Class id = "startparserservicethread"
Class = "icsharpcode. sharpdevelop. commands. startparserservicethread"/>
<! -- # Assembly preload -->
<Class id = "startsharpassemblypreloadthread"
Class = "icsharpcode. sharpdevelop. commands. startsharpassemblypreloadthread"/>
<Class id = "startworkbenchcommand"
Class = "icsharpcode. sharpdevelop. commands. startworkbenchcommand"/>
</Extension>
Note:"/Workspace/autostart" According to this descriptionClassAnd then execute their methods (ClassAll inheritIcommand)
These classes are all in the file autostartcommands. CS
WhileGuiThe main startup process is in the initializeworkbenchcommand class, as follows:
Public Class Initializeworkbenchcommand: abstractcommand
{
Const String Workbenchmemento = " Sharpdevelop. workbench. workbenchmemento " ;
Public Override Void Run ()
{
// Generate a default workbench
Defaultworkbench W = New Defaultworkbench ();
Workbenchsingleton. workbench = W;
// Start workbench
W. initializeworkspace ();
Propertyservice = (Propertyservice) servicemanager. Services. getservice ( Typeof (Propertyservice ));
// Reload information such as the previous workbench Layout
W. setmemento (ixmlconvertable) propertyservice. getproperty (workbenchmemento, New Workbenchmemento ()));
// Refresh workbench and open the pad and editor to be displayed at startup according to the layout information.
W. updatepadcontents ( Null , Null );
Workbenchsingleton. CREATEWORKSPACE ();
}
}
Ultworkbench The initializeworkspace code is as follows:
Public Void Initializeworkspace ()
{
Menu = Null ;
// Status Bar
Statusbarmanager. Control. Dock = Dockstyle. bottom;
Activeworkbenchwindowchanged + = New Eventhandler (updatemenu );
Menucomplete + = New Eventhandler (setstandardstatusbar );
Setstandardstatusbar ( Null , Null );
Iprojectservice projectservice = (Iprojectservice) icsharpcode. Core. Services. servicemanager. Services. getservice ( Typeof (Iprojectservice ));
Ifileservice fileservice = (Ifileservice) icsharpcode. Core. Services. servicemanager. Services. getservice ( Typeof (Ifileservice ));
Projectservice. currentprojectchanged + = New Projecteventhandler (setprojecttitle );
Projectservice. combineopened
+ = New Combineeventhandler (combineopened );
Fileservice. fileremoved + = New Fileeventhandler (checkremovedfile );
Fileservice. filerenamed + = New Fileeventhandler (checkrenamedfile );
Fileservice. fileremoved + = New Fileeventhandler (fileservice. recentopen. fileremoved );
Fileservice. filerenamed + = New Fileeventhandler (fileservice. recentopen. filerenamed );
//
Topmenu. Selected + = New Commandhandler (ontopmenuselected );
//
Topmenu. deselected + = New Commandhandler (ontopmenudeselected );
// Create menu
Createmainmenu ();
// Create Toolbar
Createconlbars ();
}
W. setmemento (...);
W. updatepadcontents (null, null );
These two sentences are a little more complicated and will not be analyzed here.
Note: Related Workbench , Pad And Editor For more information, see Eclipse Documentation. There are some minor differences , For example Pad In Eclipse Called View, workench In Sharpdevelop Only one Workbenchwindow . In Sharpdevelop There are multiple.