public void Run (ProgressMonitorStatusMessage progressMessage, IPackageAction action)
		{
			RunProgressMessage = progressMessage;
			ActionRun = action;

			RunAction (progressMessage, action);
		}
Exemple #2
0
        IPackageAction GetNextActionToRun()
        {
            IPackageAction action = null;

            actionsToRun.GetNextAction(out action);
            return(action);
        }
Exemple #3
0
        public void Run(IPackageAction action)
        {
            var actions = new List <IPackageAction>();

            actions.Add(action);
            Run(actions);
        }
        public void Run(ProgressMonitorStatusMessage progressMessage, IPackageAction action, bool clearConsole)
        {
            RunProgressMessage = progressMessage;
            ActionRun          = action;

            RunAction(progressMessage, action);
        }
        protected virtual void InstrumentPackageAction(IPackageAction action)
        {
            try {
                var addAction = action as InstallPackageAction;
                if (addAction != null)
                {
                    InstrumentPackageOperations(addAction.Operations);
                    return;
                }

                var updateAction = action as UpdatePackageAction;
                if (updateAction != null)
                {
                    InstrumentPackageOperations(updateAction.Operations);
                    return;
                }

                var removeAction = action as UninstallPackageAction;
                if (removeAction != null)
                {
                    var metadata = new Dictionary <string, string> ();

                    metadata ["PackageId"] = removeAction.GetPackageId();
                    var version = removeAction.GetPackageVersion();
                    if (version != null)
                    {
                        metadata ["PackageVersion"] = version.ToString();
                    }

                    UninstallPackageCounter.Inc(1, null, metadata);
                }
            } catch (Exception ex) {
                LoggingService.LogError("Instrumentation Failure in PackageManagement", ex);
            }
        }
Exemple #6
0
 /// <summary>
 /// Adds specified instance of refactoring option or overwrites the existing one with the same name.
 /// </summary>
 public void Add(IPackageAction action)
 {
     if (action != null && !data.Contains(action))
     {
         data.Add(action);
     }
 }
		public void Run(IPackageAction action)
		{
			if (ShouldRunActionInConsole(action)) {
				ReportScriptsWillNotBeRun();
			}
			
			action.Execute();
		}
		public void Run(IPackageAction action)
		{
			if (ShouldRunActionInConsole(action)) {
				consolePackageActionRunner.Run(action);
			} else {
				action.Execute();
			}
		}
 void UpdatePackage(ProgressMonitorStatusMessage progressMessage, IPackageAction action)
 {
     try {
         PackageManagementServices.BackgroundPackageActionRunner.Run(progressMessage, action);
     } catch (Exception ex) {
         PackageManagementServices.BackgroundPackageActionRunner.ShowError(progressMessage, ex);
     }
 }
Exemple #10
0
        public void GetNextAction_NewInstance_ReturnsFalse()
        {
            CreateActions();
            IPackageAction action = null;
            bool           result = actions.GetNextAction(out action);

            Assert.IsFalse(result);
        }
Exemple #11
0
        public void Run(IPackageAction action)
        {
            if (ShouldRunActionInConsole(action))
            {
                ReportScriptsWillNotBeRun();
            }

            action.Execute();
        }
Exemple #12
0
        /// <summary>
        /// Sets the configuration description for given action.
        /// </summary>
        public void UpdateConfiguration(Type actionType, PersistentStorageData config)
        {
            IPackageAction action = actions.Get(actionType);

            if (action != null)
            {
                action.Configuration = config;
            }
        }
        void ExecutePackageActions()
        {
            IPackageAction action = null;

            while (GetNextAction(out action))
            {
                Execute(action);
            }
        }
        void RemoveMultiplePackage(PackageDependencyNode[] nodes, ProgressMonitorStatusMessage progressMessage)
        {
            var project = nodes[0].Project;

            string[]       packageIds = nodes.Select(node => node.Name).ToArray();
            IPackageAction action     = PackageReferenceNodeCommandHandler.CreateUninstallPackagesAction(project, packageIds);

            PackageManagementServices.BackgroundPackageActionRunner.Run(progressMessage, action);
        }
Exemple #15
0
        /// <summary>
        /// Calls an update method related with given button on the configuration GUI.
        /// </summary>
        public void UpdateExecute(Type actionType, EventArgs e)
        {
            IPackageAction action = actions.Get(actionType);

            if (action != null)
            {
                action.Execute(null, e);
            }
        }
        public void AddPackage_PackageAddedSuccessfully_PackageIsUpdated()
        {
            CreateViewModel();
            viewModel.AddPackage();

            IPackageAction actionExecuted = fakeActionRunner.ActionPassedToRun;

            Assert.AreEqual(FirstUpdatePackageActionCreated, actionExecuted);
        }
Exemple #17
0
        public void GetNextAction_OneActionAdded_ReturnsTrue()
        {
            CreateActions();
            ProcessPackageAction expectedAction = AddAction();

            IPackageAction action = null;
            bool           result = actions.GetNextAction(out action);

            Assert.IsTrue(result);
        }
Exemple #18
0
        public void Run_ConsoleHostIsRunning_ActionAddedToPackageActionsToBeRun()
        {
            CreateRunner();
            ConsoleHostIsRunning();
            FakeInstallPackageAction expectedAction = RunInstallActionWithOneOperation();

            IPackageAction actionAdded = GetNextActionToRun();

            Assert.AreEqual(expectedAction, actionAdded);
        }
Exemple #19
0
 protected override void Run()
 {
     try {
         ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInProjectMessage();
         IPackageAction action = CreateRestorePackagesAction(GetSelectedDotNetProject());
         PackageManagementServices.BackgroundPackageActionRunner.Run(message, action);
     } catch (Exception ex) {
         ShowStatusBarError(ex);
     }
 }
 public static void Run(DotNetProject project)
 {
     try {
         ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInProjectMessage();
         IPackageAction action = CreateRestorePackagesAction(project);
         PackageManagementServices.BackgroundPackageActionRunner.Run(message, action);
     } catch (Exception ex) {
         ShowStatusBarError(ex);
     }
 }
Exemple #21
0
 public static void Run(DotNetProject project, bool restoreTransitiveProjectReferences, bool reevaluateBeforeRestore = false)
 {
     try {
         ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInProjectMessage();
         IPackageAction action = CreateRestorePackagesAction(project, restoreTransitiveProjectReferences, reevaluateBeforeRestore);
         PackageManagementServices.BackgroundPackageActionRunner.Run(message, action);
     } catch (Exception ex) {
         ShowStatusBarError(ex);
     }
 }
Exemple #22
0
 public void Run(IPackageAction action)
 {
     if (ShouldRunActionInConsole(action))
     {
         consolePackageActionRunner.Run(action);
     }
     else
     {
         action.Execute();
     }
 }
Exemple #23
0
        public void GetNextAction_CalledTwiceWithOneActionAdded_ReturnsNullActionInOutParameterOnSecondCall()
        {
            CreateActions();
            IPackageAction expectedAction = AddAction();
            IPackageAction action         = null;

            actions.GetNextAction(out action);
            actions.GetNextAction(out action);

            Assert.IsNull(action);
        }
		bool ShouldRunActionInConsole(IPackageAction action)
		{
			if (action.HasPackageScriptsToRun()) {
				if (powerShellDetection.IsPowerShell2Installed()) {
					return true;
				} else {
					ReportPowerShellIsNotInstalled();
				}
			}
			return false;
		}
		public void InstrumentPackageAction (IPackageAction action) 
		{
			try {
				var provider = action as INuGetProjectActionsProvider;
				if (provider != null) {
					InstrumentPackageActions (provider.GetNuGetProjectActions ());
				}
			} catch (Exception ex) {
				LoggingService.LogError ("Instrumentation Failure in PackageManagement", ex);
			}
		}
Exemple #26
0
        /// <summary>
        /// Gets the configuration description assigned to given actin.
        /// </summary>
        public PersistentStorageData ProvideConfiguration(Type actionType)
        {
            IPackageAction action = actions.Get(actionType);

            if (action != null)
            {
                return(action.Configuration);
            }

            return(null);
        }
        public void Run_InstallActionHasOnePowerShellScript_ActionIsPassedToConsoleToRun()
        {
            CreateRunner();
            CreateInstallActionWithOnePowerShellScript();
            powerShellDetection.IsPowerShell2InstalledReturnValue = true;
            Run();

            IPackageAction action = fakeConsoleActionRunner.ActionPassedToRun;

            Assert.AreEqual(fakeAction, action);
        }
Exemple #28
0
 public static string GetSampleOrDefault(this IPackageAction action)
 {
     try
     {
         return(action.SampleXml().OuterXml);
     }
     catch
     {
         return(string.Format("<Action runat=\"install\" alias=\"{0}\"/>", action.Alias()));
     }
 }
Exemple #29
0
        public void GetNextAction_OneActionAdded_ReturnsActionInOutParameter()
        {
            CreateActions();
            ProcessPackageAction expectedAction = AddAction();

            IPackageAction action = null;

            actions.GetNextAction(out action);

            Assert.AreEqual(expectedAction, action);
        }
Exemple #30
0
        List <IPackageAction> GetNextActionsToRun()
        {
            var            actions = new List <IPackageAction>();
            IPackageAction action  = null;

            while (actionsToRun.GetNextAction(out action))
            {
                actions.Add(action);
            }
            return(actions);
        }
Exemple #31
0
 public void InstrumentPackageAction(IPackageAction action)
 {
     try {
         var provider = action as INuGetProjectActionsProvider;
         if (provider != null)
         {
             InstrumentPackageActions(provider.GetNuGetProjectActions());
         }
     } catch (Exception ex) {
         LoggingService.LogError("Instrumentation Failure in PackageManagement", ex);
     }
 }
Exemple #32
0
        public void GetNextAction_CalledTwiceWithTwoActionsAdded_ReturnsSecondActionAddedInOutParameter()
        {
            CreateActions();
            AddAction();
            IPackageAction expectedAction = AddAction();
            IPackageAction action         = null;

            actions.GetNextAction(out action);
            actions.GetNextAction(out action);

            Assert.AreEqual(expectedAction, action);
        }
		IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance (IPackageAction action)
		{
			var processPackageActions = action as ProcessPackageOperationsAction;
			if (processPackageActions == null) {
				return new IPackage [0];
			}

			return processPackageActions.GetInstallOperations ()
				.Select (operation => operation.Package)
				.Where (package => PackageRequiresLicenseAcceptance (package))
				.ToList ();
		}
Exemple #34
0
        public void GetNextAction_CalledTwiceWithOneActionAdded_ReturnsFalseOnSecondCall()
        {
            CreateActions();
            IPackageAction expectedAction = AddAction();

            IPackageAction action = null;

            actions.GetNextAction(out action);
            bool result = actions.GetNextAction(out action);

            Assert.IsFalse(result);
        }
        bool AcceptLicenses()
        {
            var             packagesWithLicenses = new PackagesRequiringLicenseAcceptance(Project);
            var             actions  = new IPackageAction [] { this };
            List <IPackage> packages = packagesWithLicenses.GetPackagesRequiringLicenseAcceptance(actions).ToList();

            if (packages.Any())
            {
                return(packageManagementEvents.OnAcceptLicenses(packages));
            }

            return(true);
        }
Exemple #36
0
        public void PackageAction_InitializeFewTimes()
        {
            IPackageAction action = CreatePackageAction();

            mock.ReplayAll();

            // try to initialize few times:
            action.Initialize(null, null);
            action.Initialize(null, null);
            action.Destroy();

            ThrowCounterException(1);
        }
		public bool GetNextAction(out IPackageAction action)
		{
			return actions.TryDequeue(out action);
		}
		public void AddAction(IPackageAction action)
		{
			actions.Enqueue(action);
		}
		void UpdatePackage (ProgressMonitorStatusMessage progressMessage, IPackageAction action)
		{
			try {
				PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, action);
			} catch (Exception ex) {
				PackageManagementServices.BackgroundPackageActionRunner.ShowError (progressMessage, ex);
			}
		}
		void AddNewActionToRun(IPackageAction action)
		{
			packageActionsToRun.AddAction(action);
		}
 public override void Run(IPackageAction action)
 {
     base.Run(action);
     throw ExceptionToThrow;
 }
		bool ShouldRunActionInConsole(IPackageAction action)
		{
			return action.HasPackageScriptsToRun();
		}
		bool AcceptLicenses ()
		{
			var packagesWithLicenses = new PackagesRequiringLicenseAcceptance (Project);
			var actions = new IPackageAction [] { this };
			List<IPackage> packages = packagesWithLicenses.GetPackagesRequiringLicenseAcceptance (actions).ToList ();
			if (packages.Any ()) {
				return packageManagementEvents.OnAcceptLicenses (packages);
			}

			return true;
		}
		public void Run(IPackageAction action)
		{
			var actions = new List<IPackageAction>();
			actions.Add(action);
			Run(actions);
		}
		protected virtual void InstrumentPackageAction (IPackageAction action) 
		{
			try {
				var addAction = action as InstallPackageAction;
				if (addAction != null) {
					InstrumentPackageOperations (addAction.Operations);
					return;
				}

				var updateAction = action as UpdatePackageAction;
				if (updateAction != null) {
					InstrumentPackageOperations (updateAction.Operations);
					return;
				}

				var removeAction = action as UninstallPackageAction;
				if (removeAction != null) {
					var metadata = new Dictionary<string, string> ();

					metadata ["PackageId"] = removeAction.GetPackageId ();
					var version = removeAction.GetPackageVersion ();
					if (version != null)
						metadata ["PackageVersion"] = version.ToString ();

					UninstallPackageCounter.Inc (1, null, metadata);
				}
			} catch (Exception ex) {
				LoggingService.LogError ("Instrumentation Failure in PackageManagement", ex);
			}
		}
		public void Run (ProgressMonitorStatusMessage progressMessage, IPackageAction action)
		{
			Run (progressMessage, new IPackageAction [] { action });
		}
		public virtual void Run(IPackageAction action)
		{
			IsRunCalled = true;
			ActionPassedToRun = action;
			ActionsPassedToRun.Add(action);
		}
		bool GetNextAction(out IPackageAction action)
		{
			return actionsToRun.GetNextAction(out action);
		}
		void Execute(IPackageAction action)
		{
			action.PackageScriptRunner = this;
			action.Execute();
		}