コード例 #1
0
        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;
        }
コード例 #2
0
 public ExampleViewModel(IWorkspaceItemViewModelFactory workspaceItemViewModelFactory)
 {
     AddItemCommand = new ActionCommand(() =>
     {
         var newItem = workspaceItemViewModelFactory.CreateWorkspaceItem();
         WorkspaceItems.Add(newItem);
     });
 }
コード例 #3
0
 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");
         }
     });
 }