winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

VagueCriteriaException.cs (1665B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="VagueCriteriaException.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.WinGet.Client.Engine.Exceptions
      8 {
      9     using System;
     10     using System.Collections.Generic;
     11     using System.Management.Automation;
     12     using Microsoft.Management.Deployment;
     13     using Microsoft.WinGet.Client.Engine.Extensions;
     14     using Microsoft.WinGet.Resources;
     15 
     16     /// <summary>
     17     /// Raised when search criteria for installing or updating a package is too vague.
     18     /// </summary>
     19     [Serializable]
     20     internal class VagueCriteriaException : RuntimeException
     21     {
     22         /// <summary>
     23         /// Initializes a new instance of the <see cref="VagueCriteriaException"/> class.
     24         /// </summary>
     25         /// <param name="results">The list of conflicting packages of length at least two.</param>
     26         public VagueCriteriaException(IReadOnlyList<MatchResult> results)
     27             : base(string.Format(
     28                 Resources.VagueCriteriaExceptionMessage,
     29                 results[0].CatalogPackage.ToString(null),
     30                 results[1].CatalogPackage.ToString(null),
     31                 results.Count - 2))
     32         {
     33             this.MatchResults = results;
     34         }
     35 
     36         /// <summary>
     37         /// Gets the list of conflicting packages.
     38         /// </summary>
     39         public IReadOnlyList<MatchResult> MatchResults { get; private set; }
     40     }
     41 }