




























参见:Fbt2008的大作 SharpDevelop源码分析笔记(一)
源文档 <http://www.cnblogs.com/fbt2008/archive/2005/08/02/205785.aspx?Pending=true>
在Fbt2008的大作中描述了SharpDevelop其Runtime的启动过程,我把其中GUI启动补充一下。
其中写到如下系统代码启动片断
系统代码:
//这段代码就是程序启动时加载前台插件了,/Workspace/Autostart是系统自动运行命令的扩展点路径,定义在这个路径下的插件会在系统启动的时候自动运行。在这里,通过插件树初始化建立处于这个路径下的Command(命令),并逐一执行。BuildChildItems方法的功能是建立这个扩展点下的Command列表
commands = AddInTreeSingleton.AddInTree.GetTreeNode("/Workspace/Autostart").BuildChildItems(null);
for (int i = 0; i < commands.Count - 1; ++i)
{
((ICommand)commands[i]).Run();
}
}
这段代码会载入如下清单文件,并根据此清单文件中的ClassId载入运行
插件清单之一(SharpDevelopCore.addin文件)
片断
<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>
大家注意了:"/Workspace/Autostart" 就是上面代码根据此描述将这一段的描述中的Class的实例载入,然后执行他们的方法(这些Class都继承了Icommand)
这些类都在文件AutostartCommands.cs中
而GUI的主要启动过程就在InitializeWorkbenchCommand类上,如下:
DefaultWorkbench 的 InitializeWorkspace代码如下
w.SetMemento(...);
w.UpdatePadContents(null, null);
这两句稍稍复杂些,在这里就不分析了。
注意:有关Workbench,pad和Editor等概念基本可以参照Eclipse文档。有一些细小差别,例如Pad在Eclipse中叫View,Workench在SharpDevelop仅存在一个WorkbenchWindow.而在SharpDevelop有多个等等。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。