/// <summary> /// Opens a workspace based on a .cshell file. /// </summary> /// <param name="cshellFile">The file path to the .cshell file.</param> /// <returns>A task that completes once the workspace is opened.</returns> public static Task OpenWorkspace(string cshellFile) { var eventAggregator = IoC.Get<IEventAggregator>(); lock (instanceLock) { if (!File.Exists(cshellFile)) Workspace.CreateWorkspaceFile(cshellFile); workspace = new Workspace(cshellFile); } //send the opening event if (eventAggregator != null) eventAggregator.Publish(new WorkspaceOpeningEventArgs(Workspace)); return Workspace.Open() .ContinueWith(t => { //send the opened event if (eventAggregator != null) eventAggregator.Publish(new WorkspaceOpenedEventArgs(Workspace)); }); }
/// <summary> /// Closes the current workspace. /// </summary> /// <returns>A task that completes once the workspace is closed.</returns> public static Task CloseWorkspace() { if (Workspace == null) { var t = new TaskCompletionSource<object>(); t.SetResult(null); return t.Task; } //send the closing event var eventAggregator = IoC.Get<IEventAggregator>(); if (eventAggregator != null) eventAggregator.Publish(new WorkspaceClosingEventArgs(Workspace)); return Workspace.Close() .ContinueWith(t => { lock (instanceLock) { workspace = null; } if (eventAggregator != null) eventAggregator.Publish(new WorkspaceClosedEventArgs()); }); }
public WorkspaceClosingEventArgs(Workspace ws) { Workspace = ws; }
public WorkspaceOpenedEventArgs(Workspace ws) { Workspace = ws; }