/// <summary>
		/// TODO: Need to handle when an uninstall fails.
		/// </summary>
		void PackageUninstalling (object sender, PackageManagementEventArgs e)
		{
			try {
				uninstalledFiles = GetFiles (e).ToList ();
			} catch (Exception ex) {
				LoggingService.LogError ("AnalyzerPackageMonitor error.", ex);
			}
		}
		void PackageUninstalled (object sender, PackageManagementEventArgs e)
		{
			try {
				//Runtime.RunInMainThread (() => {
				//	AnalyzerPackageService.RemovePackageFiles (e.Project.DotNetProject, uninstalledFiles);
				//}).Wait ();
				uninstalledFiles = new List<string> ();
			} catch (Exception ex) {
				LoggingService.LogError ("AnalyzerPackageMonitor error.", ex);
			}
		}
		void PackageInstalled (object sender, PackageManagementEventArgs e)
		{
			try {
				//var files = GetFiles (e);
				//Runtime.RunInMainThread (() => {
				//	AnalyzerPackageService.AddPackageFiles (e.Project.DotNetProject, files);
				//});
			} catch (Exception ex) {
				LoggingService.LogError ("AnalyzerPackageMonitor error.", ex);
			}
		}
		IEnumerable<string> GetFiles (PackageManagementEventArgs e)
		{
			if (String.IsNullOrEmpty (e.PackageFilePath))
				return new string[0];

			using (var packageStream = File.OpenRead (e.PackageFilePath)) {
				var zipArchive = new ZipArchive (packageStream); 

				using (var packageReader = new PackageArchiveReader (zipArchive)) {
					return packageReader
						.GetFiles ()
						.Select (file => Path.GetFullPath (Path.Combine (e.InstallPath, file)))
						.ToList ();
				}
			}
		}
Exemple #5
0
 void PackageInstalled(object sender, PackageManagementEventArgs e)
 {
     OnPackageReferenceAdded(e);
 }
Exemple #6
0
 void PackageUninstalled(object sender, PackageManagementEventArgs e)
 {
     OnPackageReferencedRemoved(e);
 }
		PackageManagementPackageReferenceEventArgs CreateEventArgs (PackageManagementEventArgs e)
		{
			return new PackageManagementPackageReferenceEventArgs (
				e.Project.DotNetProject,
				e.Package.Id,
				e.Package.Version.ToString ());
		}
		void OnPackageReferenceAdded (PackageManagementEventArgs e)
		{
			var handler = PackageReferenceAdded;
			if (handler != null) {
				handler (this, CreateEventArgs (e));
			}
		}
		void PackageInstalled (object sender, PackageManagementEventArgs e)
		{
			OnPackageReferenceAdded (e);
		}
		void PackageUninstalled (object sender, PackageManagementEventArgs e)
		{
			OnPackageReferencedRemoved (e);
		}