public void DeleteObjectWithDependencies(Guid objectId, ComponentType?componentType, HashSet <string> deletingHashSet = null)
        {
            if (deletingHashSet == null)
            {
                deletingHashSet = new HashSet <string>();
            }
            var objectkey = $"{componentType}{objectId}";

            if (deletingHashSet.Contains(objectkey))
            {
                return;
            }
            deletingHashSet.Add(objectkey);

            logVerbose?.Invoke($"Checking dependencies for {componentType} / {objectId}");
            foreach (var objectToDelete in GetDependeciesForDelete(objectId, componentType))
            {
                DeleteObjectWithDependencies(objectToDelete.DependentComponentObjectId.Value, objectToDelete.DependentComponentTypeEnum, deletingHashSet);
            }

            switch (componentType)
            {
            case ComponentType.Workflow:
                var workflow = pluginRepository.GetWorkflowById(objectId);
                if (workflow.StateCode == WorkflowState.Activated)
                {
                    logVerbose?.Invoke($"Unpublishing workflow {workflow.Name}");
                    organizationService.Execute(new SetStateRequest
                    {
                        EntityMoniker = workflow.ToEntityReference(),
                        State         = new OptionSetValue((int)WorkflowState.Draft),
                        Status        = new OptionSetValue((int)Workflow_StatusCode.Draft)
                    });
                }
                if (workflow.CategoryEnum == Workflow_Category.BusinessProcessFlow)
                {
                    var entityMetadata = organizationService.GetEntityMetadata(workflow.UniqueName);
                    logVerbose?.Invoke($"Checking dependencies for BPF entity: {workflow.UniqueName}");
                    DeleteObjectWithDependencies(entityMetadata.MetadataId.Value, ComponentType.Entity, deletingHashSet);
                }

                if (workflow.CategoryEnum == Workflow_Category.BusinessProcessFlow)
                {
                    RemoveAllWorkflowsFromBpf(workflow);
                    logVerbose?.Invoke($"Preserving BPF {workflow.Name}");
                    return;
                }

                logVerbose?.Invoke($"Trying to delete {componentType} {workflow.Name}");
                organizationService.Delete(Workflow.EntityLogicalName, objectId);
                break;

            case ComponentType.SDKMessageProcessingStep:
                var step = pluginRepository.GetSdkMessageProcessingStepById(objectId);
                if (step.IsHidden.Value == true)
                {
                    logVerbose?.Invoke($"Preserving hidden SdkMessageProcessingStep {step.Name}");
                    return;
                }
                logVerbose?.Invoke($"Trying to delete {componentType} {step.Name} / {objectId}");
                organizationService.Delete(SdkMessageProcessingStep.EntityLogicalName, objectId);
                break;

            case ComponentType.PluginType:
                var type = pluginRepository.GetPluginTypeById(objectId);
                logVerbose?.Invoke($"Trying to delete {componentType} {type.Name} / {objectId}");
                organizationService.Delete(PluginType.EntityLogicalName, objectId);
                break;

            case ComponentType.PluginAssembly:
                logVerbose?.Invoke($"Trying to delete {componentType} {objectId}");
                organizationService.Delete(PluginAssembly.EntityLogicalName, objectId);
                break;

            case ComponentType.ServiceEndpoint:
                logVerbose?.Invoke($"Trying to delete {componentType} {objectId}");
                organizationService.Delete(ServiceEndpoint.EntityLogicalName, objectId);
                break;
            }
        }