Ejemplo n.º 1
0
        public DeploymentDialogViewModel(IServiceProvider services, string projectName, string directoryOfProjectToDeploy, string targetFrameworkMoniker)
            : base(services)
        {
            _errorDialogService  = services.GetRequiredService <IErrorDialog>();
            TasExplorerViewModel = services.GetRequiredService <ITasExplorerViewModel>();

            OutputView      = ViewLocatorService.GetViewByViewModelName(nameof(ViewModels.OutputViewModel)) as IView;
            OutputViewModel = OutputView?.ViewModel as IOutputViewModel;

            DeploymentInProgress = false;
            PathToProjectRootDir = directoryOfProjectToDeploy;
            SelectedBuildpacks   = new ObservableCollection <string>();

            if (targetFrameworkMoniker.StartsWith(FullFrameworkTFM))
            {
                _fullFrameworkDeployment = true;
            }

            CfInstanceOptions       = new List <CloudFoundryInstance>();
            CfOrgOptions            = new List <CloudFoundryOrganization>();
            CfSpaceOptions          = new List <CloudFoundrySpace>();
            BuildpackOptions        = new List <BuildpackListItem>();
            StackOptions            = new List <string>();
            DeploymentDirectoryPath = null;

            ManifestModel = new AppManifest
            {
                Version      = 1,
                Applications = new List <AppConfig>
                {
                    new AppConfig
                    {
                        Name       = projectName,
                        Buildpacks = new List <string>(),
                    }
                }
            };

            SetManifestIfDefaultExists();

            if (TasExplorerViewModel.TasConnection != null)
            {
                TargetName = TasExplorerViewModel.TasConnection.DisplayText;
                IsLoggedIn = true;

                ThreadingService.StartTask(UpdateCfOrgOptions);
                ThreadingService.StartTask(UpdateBuildpackOptions);
                ThreadingService.StartTask(UpdateStackOptions);
            }

            _projectName = projectName;

            Expanded = false;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PushToCloudFoundryCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file).
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="commandService">Command service to add command to, not null.</param>
        private PushToCloudFoundryCommand(AsyncPackage package, OleMenuCommandService commandService, IServiceProvider services)
        {
            this._package  = package ?? throw new ArgumentNullException(nameof(package));
            commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));

            _services = services;

            _dialogService = services.GetRequiredService <IErrorDialog>();

            var menuCommandID = new CommandID(CommandSet, CommandId);
            var menuItem      = new MenuCommand(Execute, menuCommandID);

            commandService.AddCommand(menuItem);
        }
 public BindingProjectGenerator(
     ISettings settings,
     IAndroidSdkDialog androidSdkDialog,
     IBindingProjectGenerator bindingProjectGenerator,
     IDependencyInputDialog dependencyInputDialog,
     IDependencyOutputSelectorDialog dependencyOutputSelectorDialog,
     IErrorDialog errorDialog)
 {
     _settings                       = settings;
     _androidSdkDialog               = androidSdkDialog;
     _bindingProjectGenerator        = bindingProjectGenerator;
     _dependencyInputDialog          = dependencyInputDialog;
     _dependencyOutputSelectorDialog = dependencyOutputSelectorDialog;
     _errorDialog                    = errorDialog;
 }
 public BindingProjectGenerator(
     ISettings settings,
     IAndroidSdkDialog androidSdkDialog,
     IBindingProjectGenerator bindingProjectGenerator,
     IDependencyInputDialog dependencyInputDialog, 
     IDependencyOutputSelectorDialog dependencyOutputSelectorDialog, 
     IErrorDialog errorDialog)
 {
     _settings = settings;
     _androidSdkDialog = androidSdkDialog;
     _bindingProjectGenerator = bindingProjectGenerator;
     _dependencyInputDialog = dependencyInputDialog;
     _dependencyOutputSelectorDialog = dependencyOutputSelectorDialog;
     _errorDialog = errorDialog;
 }
        public CfInstanceViewModel(CloudFoundryInstance cloudFoundryInstance, TasExplorerViewModel parentTasExplorer, IServiceProvider services, bool expanded = false)
            : base(null, parentTasExplorer, services, expanded: expanded)
        {
            _dialogService       = services.GetRequiredService <IErrorDialog>();
            CloudFoundryInstance = cloudFoundryInstance;
            DisplayText          = CloudFoundryInstance.InstanceName;

            LoadingPlaceholder = new PlaceholderViewModel(parent: this, services)
            {
                DisplayText = _loadingMsg,
            };

            EmptyPlaceholder = new PlaceholderViewModel(parent: this, Services)
            {
                DisplayText = _emptyOrgsPlaceholderMsg,
            };
        }
        public SpaceViewModel(CloudFoundrySpace space, OrgViewModel parentOrgViewModel, TasExplorerViewModel parentTasExplorer, IServiceProvider services, bool expanded = false)
            : base(parentOrgViewModel, parentTasExplorer, services, expanded: expanded)
        {
            _dialogService = services.GetRequiredService <IErrorDialog>();
            Space          = space;
            DisplayText    = Space.SpaceName;

            LoadingPlaceholder = new PlaceholderViewModel(parent: this, services)
            {
                DisplayText = LoadingMsg,
            };

            EmptyPlaceholder = new PlaceholderViewModel(parent: this, Services)
            {
                DisplayText = EmptyAppsPlaceholderMsg,
            };
        }
        public OrgViewModel(CloudFoundryOrganization org, CfInstanceViewModel parentCfInstanceViewModel, TasExplorerViewModel parentTasExplorer, IServiceProvider services, bool expanded = false)
            : base(parentCfInstanceViewModel, parentTasExplorer, services, expanded: expanded)
        {
            _dialogService = services.GetRequiredService <IErrorDialog>();

            Org         = org;
            DisplayText = Org.OrgName;

            LoadingPlaceholder = new PlaceholderViewModel(parent: this, services)
            {
                DisplayText = _loadingMsg,
            };

            EmptyPlaceholder = new PlaceholderViewModel(parent: this, Services)
            {
                DisplayText = _emptySpacesPlaceholderMsg,
            };
        }
        /// <summary>
        /// Initializes the command.
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="services">IServiceProvider used to lookup auxiliary services.</param>
        public static async Task InitializeAsync(AsyncPackage package, IServiceProvider services)
        {
            // Switch to the main thread - the call to AddCommand in OpenLogsCommand's constructor requires
            // the UI thread.
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

            OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            Instance = new OpenLogsCommand(package, commandService);

            Dte = await package.GetServiceAsync(typeof(DTE)) as DTE2;

            _fileService   = services.GetRequiredService <IFileService>();
            _dialogService = services.GetRequiredService <IErrorDialog>();
            var logSvc = services.GetRequiredService <ILoggingService>();

            Assumes.Present(Dte);
            Assumes.Present(_fileService);
            Assumes.Present(_dialogService);
            Assumes.Present(logSvc);

            _logger = logSvc.Logger;
        }
        public TasExplorerViewModel(IServiceProvider services)
            : base(services)
        {
            _errorDialogService     = services.GetRequiredService <IErrorDialog>();
            _threadingService       = services.GetRequiredService <IThreadingService>();
            _dataPersistenceService = services.GetRequiredService <IDataPersistenceService>();
            _confirmDelete          = services.GetRequiredService <IAppDeletionConfirmationViewModel>();
            _viewLocatorService     = services.GetRequiredService <IViewLocatorService>();

            string existingSavedConnectionName    = _dataPersistenceService.ReadStringData(ConnectionNameKey);
            string existingSavedConnectionAddress = _dataPersistenceService.ReadStringData(ConnectionAddressKey);
            bool   savedConnectionCredsExist      = CloudFoundryService.IsValidConnection();

            if (existingSavedConnectionName == null || existingSavedConnectionAddress == null || !savedConnectionCredsExist)
            {
                TasConnection = null;
            }
            else
            {
                var restoredConnection = new CloudFoundryInstance(name: existingSavedConnectionName, apiAddress: existingSavedConnectionAddress);

                SetConnection(restoredConnection);
            }
        }
Ejemplo n.º 10
0
 public AppDeletionConfirmationViewModel(IServiceProvider services) : base(services)
 {
     _errorDialogService = services.GetRequiredService <IErrorDialog>();
 }