Dev2.Studio.UserInterfaceLayoutProvider.DeleteWorkflowExplorerResource C# (CSharp) Method

DeleteWorkflowExplorerResource() private method

private DeleteWorkflowExplorerResource ( object state ) : void
state object
return void
        private void DeleteWorkflowExplorerResource(object state)
        {
            if (!(state is KeyValuePair<ITreeNode, IContextualResourceModel>)) return;

            var kvp = (KeyValuePair<ITreeNode, IContextualResourceModel>)state;
            IContextualResourceModel model = kvp.Value;
            List<IResourceModel> dependencies = ResourceDependencyService.GetUniqueDependencies(model);
            bool openDependencyGraph;
            bool shouldRemove = QueryDeleteExplorerResource(model.ResourceName, "Workflow",
                                                            dependencies != null && dependencies.Count > 0,
                                                            out openDependencyGraph);

            if (shouldRemove)
            {
                if (!WizardEngine.IsWizard(model))
                {
                    IContextualResourceModel wizard = WizardEngine.GetWizard(model);
                    if (wizard != null)
                    {
                        UnlimitedObject wizardData = ExecuteDeleteResource(wizard, "WorkflowService",
                                                                           String.Join(",",
                                                                                       MainViewModel.SecurityContext
                                                                                                    .Roles));

                        if (wizardData.HasError)
                        {
                            HandleDeleteResourceError(wizardData, model.ResourceName, "WorkflowService");
                            return;
                        }
                    }
                }

                UnlimitedObject data = ExecuteDeleteResource(model, "WorkflowService",
                                                             String.Join(",", MainViewModel.SecurityContext.Roles));

                if (data.HasError)
                {
                    HandleDeleteResourceError(data, model.ResourceName, "WorkflowService");
                }
                else
                {
                    RemoveExplorerResource(model, kvp.Key);
                }
            }
            else if (openDependencyGraph)
            {
                MainViewModel.AddDependencyVisualizerDocument(model);
            }
        }