public void AddWorkspaceItem(IContextualResourceModel model) { if (model == null) { throw new ArgumentNullException("model"); } var workspaceItem = WorkspaceItems.FirstOrDefault(wi => wi.ID == model.ID && wi.EnvironmentID == model.Environment.EnvironmentID); if (workspaceItem != null) { return; } var context = model.Environment.Connection; WorkspaceItems.Add(new WorkspaceItem(context.WorkspaceID, context.ServerID, model.Environment.EnvironmentID, model.ID) { ServiceName = model.ResourceName, IsWorkflowSaved = model.IsWorkflowSaved, ServiceType = model.ResourceType == ResourceType.Source ? WorkspaceItem.SourceServiceType : WorkspaceItem.ServiceServiceType, }); Write(); model.OnResourceSaved += UpdateWorkspaceItemIsWorkflowSaved; }
public ExampleViewModel(IWorkspaceItemViewModelFactory workspaceItemViewModelFactory) { AddItemCommand = new ActionCommand(() => { var newItem = workspaceItemViewModelFactory.CreateWorkspaceItem(); WorkspaceItems.Add(newItem); }); }
internal void Update(WorkspaceItem pWorkspaceItem) { uiFactory.StartNew(() => { lock (WorkspaceItems) { for (var i = 0; i < WorkspaceItems.Count; i++) { if (WorkspaceItems[i].ID.Equals(pWorkspaceItem.ID)) { WorkspaceItems[i].Update(pWorkspaceItem); return; } } WorkspaceItems.Add(new WorkspaceItemViewModel(pWorkspaceItem)); OnPropertyChanged("SourceFiles"); } }); }