public async Task <ProjectResult> AddProjectAsync(string title) { var newProject = await PostAsync <ProjectResult, ProjectModel>(new ProjectModel { Title = title }); OnProjectAdded.Invoke(newProject); return(newProject); }
public async System.Threading.Tasks.Task EnqueueAsync(Project project) { if (!_projects.ContainsKey(project.Id)) { await System.Threading.Tasks.Task.Run(() => { _projects.TryAdd(project.Id, new Lazy <Project>(() => project)); foreach (var document in project.Documents) { _tasks.Enqueue(CreateIndexingTask(project.Id, document.Id)); } OnProjectAdded?.Invoke(this, EventArgs.Empty); }); } }
public void AddProject(Project p) { TargetWorkspace.Projects.Add(p.ProjectGuid, p); var workspaceFile = TargetWorkspace.WorkspaceFile; var root = workspaceFile.SelectSingleNode("//Workspace"); XmlElement element = workspaceFile.CreateElement("Project"); var guidAttr = workspaceFile.CreateAttribute("GUID"); var pathAttr = workspaceFile.CreateAttribute("Path"); guidAttr.Value = p.ProjectGuid.ToString(); pathAttr.Value = p.ProjFilepath; element.Attributes.Append(guidAttr); element.Attributes.Append(pathAttr); TargetWorkspace.SaveWorkspace(); // Raise OnWorkspaceOpened event OnProjectAdded?.Invoke(this, new ProjectAddedEventArgs(p)); Tree.treeView1.Nodes[0].Nodes.Add(PopulateProjectNode(p)); }