/// <summary> /// Create a new AppDomain to host SharpDevelop. /// </summary> public StartUpHost(StartupSettings startup) { if (startup == null) { throw new ArgumentNullException("startup"); } this.appDomain = CreateDomain(); helper = (CallHelper)appDomain.CreateInstanceAndUnwrap(SdaAssembly.FullName, typeof(CallHelper).FullName); helper.InitSharpDevelopCore(new CallbackHelper(this), startup); initStatus = FWInitStatus.CoreInitialized; }
/// <summary> /// Unload the SharpDevelop AppDomain. This will force SharpDevelop to close /// without saving open files or changed settings. /// Call CloseWorkbench before UnloadDomain to prompt the user to save documents and settings. /// </summary> public void UnloadDomain() { if (initStatus != FWInitStatus.AppDomainUnloaded) { if (initStatus == FWInitStatus.WorkbenchInitialized) { helper.KillWorkbench(); } AppDomain.Unload(appDomain); initStatus = FWInitStatus.AppDomainUnloaded; } }
/// <summary> /// Initializes the workbench (create the MainForm instance, construct menu from AddInTree etc.) /// and runs it using the supplied settings. /// This starts a new message loop for the workbench. By default the message loop /// is created on a new thread, but you can change the settings so that /// it is created on the thread calling RunWorkbench. /// In that case, RunWorkbench will block until SharpDevelop is shut down! /// </summary> public void RunWorkbench(WorkbenchSettings settings) { if (settings == null) { throw new ArgumentNullException("settings"); } if (initStatus == FWInitStatus.CoreInitialized) { initStatus = FWInitStatus.Busy; helper.RunWorkbench(settings); if (settings.RunOnNewThread) { initStatus = FWInitStatus.WorkbenchInitialized; } } else { throw new InvalidOperationException(); } }