winget-cli

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

Converters.cpp (29938B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #include "pch.h"
      4 #include <AppInstallerErrors.h>
      5 #include <winget/RepositorySource.h>
      6 #include "Microsoft/PredefinedInstalledSourceFactory.h"
      7 #include "Workflows/WorkflowBase.h"
      8 #include "Converters.h"
      9 
     10 namespace winrt::Microsoft::Management::Deployment::implementation
     11 {
     12     Microsoft::Management::Deployment::PackageMatchField GetDeploymentMatchField(::AppInstaller::Repository::PackageMatchField field)
     13     {
     14         Microsoft::Management::Deployment::PackageMatchField matchField = Microsoft::Management::Deployment::PackageMatchField::Id;
     15         switch (field)
     16         {
     17         case ::AppInstaller::Repository::PackageMatchField::Command:
     18             matchField = Microsoft::Management::Deployment::PackageMatchField::Command;
     19             break;
     20         case ::AppInstaller::Repository::PackageMatchField::Id:
     21             matchField = Microsoft::Management::Deployment::PackageMatchField::Id;
     22             break;
     23         case ::AppInstaller::Repository::PackageMatchField::Moniker:
     24             matchField = Microsoft::Management::Deployment::PackageMatchField::Moniker;
     25             break;
     26         case ::AppInstaller::Repository::PackageMatchField::Name:
     27             matchField = Microsoft::Management::Deployment::PackageMatchField::Name;
     28             break;
     29         case ::AppInstaller::Repository::PackageMatchField::Tag:
     30             matchField = Microsoft::Management::Deployment::PackageMatchField::Tag;
     31             break;
     32         case ::AppInstaller::Repository::PackageMatchField::ProductCode:
     33             matchField = Microsoft::Management::Deployment::PackageMatchField::ProductCode;
     34             break;
     35         case ::AppInstaller::Repository::PackageMatchField::PackageFamilyName:
     36             matchField = Microsoft::Management::Deployment::PackageMatchField::PackageFamilyName;
     37             break;
     38         default:
     39             matchField = Microsoft::Management::Deployment::PackageMatchField::Id;
     40             break;
     41         }
     42         return matchField;
     43     }
     44 
     45     ::AppInstaller::Repository::PackageMatchField GetRepositoryMatchField(Microsoft::Management::Deployment::PackageMatchField field)
     46     {
     47         ::AppInstaller::Repository::PackageMatchField matchField = ::AppInstaller::Repository::PackageMatchField::Id;
     48         switch (field)
     49         {
     50         case Microsoft::Management::Deployment::PackageMatchField::Command:
     51             matchField = ::AppInstaller::Repository::PackageMatchField::Command;
     52             break;
     53         case Microsoft::Management::Deployment::PackageMatchField::Id:
     54             matchField = ::AppInstaller::Repository::PackageMatchField::Id;
     55             break;
     56         case Microsoft::Management::Deployment::PackageMatchField::Moniker:
     57             matchField = ::AppInstaller::Repository::PackageMatchField::Moniker;
     58             break;
     59         case Microsoft::Management::Deployment::PackageMatchField::Name:
     60             matchField = ::AppInstaller::Repository::PackageMatchField::Name;
     61             break;
     62         case Microsoft::Management::Deployment::PackageMatchField::Tag:
     63             matchField = ::AppInstaller::Repository::PackageMatchField::Tag;
     64             break;
     65         case Microsoft::Management::Deployment::PackageMatchField::ProductCode:
     66             matchField = ::AppInstaller::Repository::PackageMatchField::ProductCode;
     67             break;
     68         case Microsoft::Management::Deployment::PackageMatchField::PackageFamilyName:
     69             matchField = ::AppInstaller::Repository::PackageMatchField::PackageFamilyName;
     70             break;
     71         default:
     72             matchField = ::AppInstaller::Repository::PackageMatchField::Id;
     73             break;
     74         }
     75         return matchField;
     76     }
     77 
     78     Microsoft::Management::Deployment::PackageFieldMatchOption GetDeploymentMatchOption(::AppInstaller::Repository::MatchType type)
     79     {
     80         Microsoft::Management::Deployment::PackageFieldMatchOption matchOption = Microsoft::Management::Deployment::PackageFieldMatchOption::Equals;
     81         switch (type)
     82         {
     83         case ::AppInstaller::Repository::MatchType::CaseInsensitive:
     84             matchOption = Microsoft::Management::Deployment::PackageFieldMatchOption::EqualsCaseInsensitive;
     85             break;
     86         case ::AppInstaller::Repository::MatchType::Exact:
     87             matchOption = Microsoft::Management::Deployment::PackageFieldMatchOption::Equals;
     88             break;
     89         case ::AppInstaller::Repository::MatchType::StartsWith:
     90             matchOption = Microsoft::Management::Deployment::PackageFieldMatchOption::StartsWithCaseInsensitive;
     91             break;
     92         case ::AppInstaller::Repository::MatchType::Substring:
     93             matchOption = Microsoft::Management::Deployment::PackageFieldMatchOption::ContainsCaseInsensitive;
     94             break;
     95         default:
     96             matchOption = Microsoft::Management::Deployment::PackageFieldMatchOption::Equals;
     97             break;
     98         }
     99         return matchOption;
    100     }
    101 
    102     ::AppInstaller::Repository::MatchType GetRepositoryMatchType(Microsoft::Management::Deployment::PackageFieldMatchOption option)
    103     {
    104         ::AppInstaller::Repository::MatchType packageFieldMatchOption = ::AppInstaller::Repository::MatchType::Exact;
    105         switch (option)
    106         {
    107         case Microsoft::Management::Deployment::PackageFieldMatchOption::EqualsCaseInsensitive:
    108             packageFieldMatchOption = ::AppInstaller::Repository::MatchType::CaseInsensitive;
    109             break;
    110         case Microsoft::Management::Deployment::PackageFieldMatchOption::Equals:
    111             packageFieldMatchOption = ::AppInstaller::Repository::MatchType::Exact;
    112             break;
    113         case Microsoft::Management::Deployment::PackageFieldMatchOption::StartsWithCaseInsensitive:
    114             packageFieldMatchOption = ::AppInstaller::Repository::MatchType::StartsWith;
    115             break;
    116         case Microsoft::Management::Deployment::PackageFieldMatchOption::ContainsCaseInsensitive:
    117             packageFieldMatchOption = ::AppInstaller::Repository::MatchType::Substring;
    118             break;
    119         default:
    120             packageFieldMatchOption = ::AppInstaller::Repository::MatchType::Exact;
    121             break;
    122         }
    123         return packageFieldMatchOption;
    124     }
    125 
    126     ::AppInstaller::Repository::CompositeSearchBehavior GetRepositoryCompositeSearchBehavior(Microsoft::Management::Deployment::CompositeSearchBehavior searchBehavior)
    127     {
    128         ::AppInstaller::Repository::CompositeSearchBehavior repositorySearchBehavior = ::AppInstaller::Repository::CompositeSearchBehavior::AllPackages;
    129         switch (searchBehavior)
    130         {
    131         case Microsoft::Management::Deployment::CompositeSearchBehavior::LocalCatalogs:
    132             repositorySearchBehavior = ::AppInstaller::Repository::CompositeSearchBehavior::Installed;
    133             break;
    134         case Microsoft::Management::Deployment::CompositeSearchBehavior::RemotePackagesFromRemoteCatalogs:
    135             repositorySearchBehavior = ::AppInstaller::Repository::CompositeSearchBehavior::AvailablePackages;
    136             break;
    137         case Microsoft::Management::Deployment::CompositeSearchBehavior::RemotePackagesFromAllCatalogs:
    138             repositorySearchBehavior = ::AppInstaller::Repository::CompositeSearchBehavior::AvailablePackages;
    139             break;
    140         case Microsoft::Management::Deployment::CompositeSearchBehavior::AllCatalogs:
    141         default:
    142             repositorySearchBehavior = ::AppInstaller::Repository::CompositeSearchBehavior::AllPackages;
    143             break;
    144         }
    145         return repositorySearchBehavior;
    146     }
    147 
    148     ::AppInstaller::Repository::PackageVersionMetadata GetRepositoryPackageVersionMetadata(Microsoft::Management::Deployment::PackageVersionMetadataField packageVersionMetadataField)
    149     {
    150         ::AppInstaller::Repository::PackageVersionMetadata metadataKey = ::AppInstaller::Repository::PackageVersionMetadata::InstalledLocation;
    151         switch (packageVersionMetadataField)
    152         {
    153         case Microsoft::Management::Deployment::PackageVersionMetadataField::InstalledLocation:
    154             metadataKey = ::AppInstaller::Repository::PackageVersionMetadata::InstalledLocation;
    155             break;
    156         case Microsoft::Management::Deployment::PackageVersionMetadataField::InstalledScope:
    157             metadataKey = ::AppInstaller::Repository::PackageVersionMetadata::InstalledScope;
    158             break;
    159         case Microsoft::Management::Deployment::PackageVersionMetadataField::InstallerType:
    160             metadataKey = ::AppInstaller::Repository::PackageVersionMetadata::InstalledType;
    161             break;
    162         case Microsoft::Management::Deployment::PackageVersionMetadataField::PublisherDisplayName:
    163             metadataKey = ::AppInstaller::Repository::PackageVersionMetadata::Publisher;
    164             break;
    165         case Microsoft::Management::Deployment::PackageVersionMetadataField::SilentUninstallCommand:
    166             metadataKey = ::AppInstaller::Repository::PackageVersionMetadata::SilentUninstallCommand;
    167             break;
    168         case Microsoft::Management::Deployment::PackageVersionMetadataField::StandardUninstallCommand:
    169             metadataKey = ::AppInstaller::Repository::PackageVersionMetadata::StandardUninstallCommand;
    170             break;
    171         }
    172         return metadataKey;
    173     }
    174 
    175     winrt::Microsoft::Management::Deployment::FindPackagesResultStatus FindPackagesResultStatus(winrt::hresult hresult)
    176     {
    177         winrt::Microsoft::Management::Deployment::FindPackagesResultStatus resultStatus = winrt::Microsoft::Management::Deployment::FindPackagesResultStatus::Ok;
    178         switch (hresult)
    179         {
    180         case(S_OK):
    181             resultStatus = winrt::Microsoft::Management::Deployment::FindPackagesResultStatus::Ok;
    182             break;
    183         case APPINSTALLER_CLI_ERROR_BLOCKED_BY_POLICY:
    184             resultStatus = winrt::Microsoft::Management::Deployment::FindPackagesResultStatus::BlockedByPolicy;
    185             break;
    186         case APPINSTALLER_CLI_ERROR_UNSUPPORTED_RESTSOURCE:
    187         case APPINSTALLER_CLI_ERROR_RESTSOURCE_INVALID_DATA:
    188         case APPINSTALLER_CLI_ERROR_RESTAPI_ENDPOINT_NOT_FOUND:
    189         case APPINSTALLER_CLI_ERROR_RESTAPI_INTERNAL_ERROR:
    190         case APPINSTALLER_CLI_ERROR_RESTAPI_UNSUPPORTED_MIME_TYPE:
    191         case APPINSTALLER_CLI_ERROR_RESTSOURCE_INVALID_VERSION:
    192         case APPINSTALLER_CLI_ERROR_SOURCE_DATA_INTEGRITY_FAILURE:
    193             resultStatus = winrt::Microsoft::Management::Deployment::FindPackagesResultStatus::CatalogError;
    194             break;
    195         case E_INVALIDARG:
    196         case APPINSTALLER_CLI_ERROR_INVALID_CL_ARGUMENTS:
    197             resultStatus = winrt::Microsoft::Management::Deployment::FindPackagesResultStatus::InvalidOptions;
    198             break;
    199         case APPINSTALLER_CLI_ERROR_INVALID_AUTHENTICATION_INFO:
    200         case APPINSTALLER_CLI_ERROR_AUTHENTICATION_TYPE_NOT_SUPPORTED:
    201         case APPINSTALLER_CLI_ERROR_AUTHENTICATION_FAILED:
    202         case APPINSTALLER_CLI_ERROR_AUTHENTICATION_INTERACTIVE_REQUIRED:
    203         case APPINSTALLER_CLI_ERROR_AUTHENTICATION_CANCELLED_BY_USER:
    204         case APPINSTALLER_CLI_ERROR_AUTHENTICATION_INCORRECT_ACCOUNT:
    205             resultStatus = winrt::Microsoft::Management::Deployment::FindPackagesResultStatus::AuthenticationError;
    206             break;
    207         case HTTP_E_STATUS_DENIED:
    208         case HTTP_E_STATUS_FORBIDDEN:
    209             resultStatus = winrt::Microsoft::Management::Deployment::FindPackagesResultStatus::AccessDenied;
    210             break;
    211         case APPINSTALLER_CLI_ERROR_COMMAND_FAILED:
    212         case APPINSTALLER_CLI_ERROR_CANNOT_WRITE_TO_UPLEVEL_INDEX:
    213         case APPINSTALLER_CLI_ERROR_INDEX_INTEGRITY_COMPROMISED:
    214         default:
    215             resultStatus = winrt::Microsoft::Management::Deployment::FindPackagesResultStatus::InternalError;
    216             break;
    217         }
    218         return resultStatus;
    219     }
    220 
    221     std::optional<::AppInstaller::Utility::Architecture> GetUtilityArchitecture(winrt::Windows::System::ProcessorArchitecture architecture)
    222     {
    223         return ::AppInstaller::Utility::ConvertToArchitectureEnum(architecture);
    224     }
    225 
    226     std::optional<winrt::Windows::System::ProcessorArchitecture> GetWindowsSystemProcessorArchitecture(::AppInstaller::Utility::Architecture architecture)
    227     {
    228         switch (architecture)
    229         {
    230         case ::AppInstaller::Utility::Architecture::X86:
    231             return winrt::Windows::System::ProcessorArchitecture::X86;
    232         case ::AppInstaller::Utility::Architecture::Arm:
    233             return winrt::Windows::System::ProcessorArchitecture::Arm;
    234         case ::AppInstaller::Utility::Architecture::X64:
    235             return winrt::Windows::System::ProcessorArchitecture::X64;
    236         case ::AppInstaller::Utility::Architecture::Neutral:
    237             return winrt::Windows::System::ProcessorArchitecture::Neutral;
    238         case ::AppInstaller::Utility::Architecture::Arm64:
    239             return winrt::Windows::System::ProcessorArchitecture::Arm64;
    240         }
    241 
    242         return {};
    243     }
    244 
    245     std::pair<::AppInstaller::Manifest::ScopeEnum, bool> GetManifestScope(winrt::Microsoft::Management::Deployment::PackageInstallScope scope)
    246     {
    247         switch (scope)
    248         {
    249         case winrt::Microsoft::Management::Deployment::PackageInstallScope::Any:
    250             return std::make_pair(::AppInstaller::Manifest::ScopeEnum::Unknown, false);
    251         case winrt::Microsoft::Management::Deployment::PackageInstallScope::User:
    252             return std::make_pair(::AppInstaller::Manifest::ScopeEnum::User, false);
    253         case winrt::Microsoft::Management::Deployment::PackageInstallScope::System:
    254             return std::make_pair(::AppInstaller::Manifest::ScopeEnum::Machine, false);
    255         case winrt::Microsoft::Management::Deployment::PackageInstallScope::UserOrUnknown:
    256             return std::make_pair(::AppInstaller::Manifest::ScopeEnum::User, true);
    257         case winrt::Microsoft::Management::Deployment::PackageInstallScope::SystemOrUnknown:
    258             return std::make_pair(::AppInstaller::Manifest::ScopeEnum::Machine, true);
    259         }
    260 
    261         return std::make_pair(::AppInstaller::Manifest::ScopeEnum::Unknown, false);
    262     }
    263 
    264     winrt::Microsoft::Management::Deployment::PackageInstallerType GetDeploymentInstallerType(::AppInstaller::Manifest::InstallerTypeEnum installerType)
    265     {
    266         switch (installerType)
    267         {
    268         case ::AppInstaller::Manifest::InstallerTypeEnum::Burn:
    269             return Microsoft::Management::Deployment::PackageInstallerType::Burn;
    270         case ::AppInstaller::Manifest::InstallerTypeEnum::Exe:
    271             return Microsoft::Management::Deployment::PackageInstallerType::Exe;
    272         case ::AppInstaller::Manifest::InstallerTypeEnum::Inno:
    273             return Microsoft::Management::Deployment::PackageInstallerType::Inno;
    274         case ::AppInstaller::Manifest::InstallerTypeEnum::Msi:
    275             return Microsoft::Management::Deployment::PackageInstallerType::Msi;
    276         case ::AppInstaller::Manifest::InstallerTypeEnum::Msix:
    277             return Microsoft::Management::Deployment::PackageInstallerType::Msix;
    278         case ::AppInstaller::Manifest::InstallerTypeEnum::MSStore:
    279             return Microsoft::Management::Deployment::PackageInstallerType::MSStore;
    280         case ::AppInstaller::Manifest::InstallerTypeEnum::Nullsoft:
    281             return Microsoft::Management::Deployment::PackageInstallerType::Nullsoft;
    282         case ::AppInstaller::Manifest::InstallerTypeEnum::Portable:
    283             return Microsoft::Management::Deployment::PackageInstallerType::Portable;
    284         case ::AppInstaller::Manifest::InstallerTypeEnum::Wix:
    285             return Microsoft::Management::Deployment::PackageInstallerType::Wix;
    286         case ::AppInstaller::Manifest::InstallerTypeEnum::Zip:
    287             return Microsoft::Management::Deployment::PackageInstallerType::Zip;
    288         case ::AppInstaller::Manifest::InstallerTypeEnum::Unknown:
    289             return Microsoft::Management::Deployment::PackageInstallerType::Unknown;
    290         }
    291 
    292         return Microsoft::Management::Deployment::PackageInstallerType::Unknown;
    293     }
    294 
    295     ::AppInstaller::Manifest::InstallerTypeEnum GetManifestInstallerType(winrt::Microsoft::Management::Deployment::PackageInstallerType installerType)
    296     {
    297         switch (installerType)
    298         {
    299         case Microsoft::Management::Deployment::PackageInstallerType::Burn:
    300             return ::AppInstaller::Manifest::InstallerTypeEnum::Burn;
    301         case Microsoft::Management::Deployment::PackageInstallerType::Exe:
    302             return ::AppInstaller::Manifest::InstallerTypeEnum::Exe;
    303         case Microsoft::Management::Deployment::PackageInstallerType::Inno:
    304             return ::AppInstaller::Manifest::InstallerTypeEnum::Inno;
    305         case Microsoft::Management::Deployment::PackageInstallerType::Msi:
    306             return ::AppInstaller::Manifest::InstallerTypeEnum::Msi;
    307         case Microsoft::Management::Deployment::PackageInstallerType::Msix:
    308             return ::AppInstaller::Manifest::InstallerTypeEnum::Msix;
    309         case Microsoft::Management::Deployment::PackageInstallerType::MSStore:
    310             return ::AppInstaller::Manifest::InstallerTypeEnum::MSStore;
    311         case Microsoft::Management::Deployment::PackageInstallerType::Nullsoft:
    312             return ::AppInstaller::Manifest::InstallerTypeEnum::Nullsoft;
    313         case Microsoft::Management::Deployment::PackageInstallerType::Portable:
    314             return ::AppInstaller::Manifest::InstallerTypeEnum::Portable;
    315         case Microsoft::Management::Deployment::PackageInstallerType::Wix:
    316             return ::AppInstaller::Manifest::InstallerTypeEnum::Wix;
    317         case Microsoft::Management::Deployment::PackageInstallerType::Zip:
    318             return ::AppInstaller::Manifest::InstallerTypeEnum::Zip;
    319         case Microsoft::Management::Deployment::PackageInstallerType::Unknown:
    320             return ::AppInstaller::Manifest::InstallerTypeEnum::Unknown;
    321         }
    322 
    323         return ::AppInstaller::Manifest::InstallerTypeEnum::Unknown;
    324     }
    325 
    326     winrt::Microsoft::Management::Deployment::PackageInstallerScope GetDeploymentInstallerScope(::AppInstaller::Manifest::ScopeEnum installerScope)
    327     {
    328         switch (installerScope)
    329         {
    330         case ::AppInstaller::Manifest::ScopeEnum::User:
    331             return Microsoft::Management::Deployment::PackageInstallerScope::User;
    332         case ::AppInstaller::Manifest::ScopeEnum::Machine:
    333             return Microsoft::Management::Deployment::PackageInstallerScope::System;
    334         case ::AppInstaller::Manifest::ScopeEnum::Unknown:
    335             return Microsoft::Management::Deployment::PackageInstallerScope::Unknown;
    336         }
    337 
    338         return Microsoft::Management::Deployment::PackageInstallerScope::Unknown;
    339     }
    340 
    341     ::AppInstaller::Manifest::ScopeEnum GetManifestUninstallScope(winrt::Microsoft::Management::Deployment::PackageUninstallScope scope)
    342     {
    343         switch (scope)
    344         {
    345         case winrt::Microsoft::Management::Deployment::PackageUninstallScope::Any:
    346             return ::AppInstaller::Manifest::ScopeEnum::Unknown;
    347         case winrt::Microsoft::Management::Deployment::PackageUninstallScope::User:
    348             return ::AppInstaller::Manifest::ScopeEnum::User;
    349         case winrt::Microsoft::Management::Deployment::PackageUninstallScope::System:
    350             return ::AppInstaller::Manifest::ScopeEnum::Machine;
    351         }
    352 
    353         return ::AppInstaller::Manifest::ScopeEnum::Unknown;
    354     }
    355 
    356     ::AppInstaller::Manifest::ScopeEnum GetManifestRepairScope(winrt::Microsoft::Management::Deployment::PackageRepairScope scope)
    357     {
    358         switch (scope)
    359         {
    360         case winrt::Microsoft::Management::Deployment::PackageRepairScope::Any:
    361             return ::AppInstaller::Manifest::ScopeEnum::Unknown;
    362         case winrt::Microsoft::Management::Deployment::PackageRepairScope::User:
    363             return ::AppInstaller::Manifest::ScopeEnum::User;
    364         case winrt::Microsoft::Management::Deployment::PackageRepairScope::System:
    365             return ::AppInstaller::Manifest::ScopeEnum::Machine;
    366         }
    367 
    368         return ::AppInstaller::Manifest::ScopeEnum::Unknown;
    369     }
    370 
    371     winrt::Microsoft::Management::Deployment::ElevationRequirement GetDeploymentElevationRequirement(::AppInstaller::Manifest::ElevationRequirementEnum elevationRequirement)
    372     {
    373         switch (elevationRequirement)
    374         {
    375         case ::AppInstaller::Manifest::ElevationRequirementEnum::ElevationRequired:
    376             return Microsoft::Management::Deployment::ElevationRequirement::ElevationRequired;
    377         case ::AppInstaller::Manifest::ElevationRequirementEnum::ElevationProhibited:
    378             return Microsoft::Management::Deployment::ElevationRequirement::ElevationProhibited;
    379         case ::AppInstaller::Manifest::ElevationRequirementEnum::ElevatesSelf:
    380             return Microsoft::Management::Deployment::ElevationRequirement::ElevatesSelf;
    381         case ::AppInstaller::Manifest::ElevationRequirementEnum::Unknown:
    382             return Microsoft::Management::Deployment::ElevationRequirement::Unknown;
    383         }
    384 
    385         return Microsoft::Management::Deployment::ElevationRequirement::Unknown;
    386     }
    387 
    388     winrt::Microsoft::Management::Deployment::IconFileType GetDeploymentIconFileType(::AppInstaller::Manifest::IconFileTypeEnum iconFileType)
    389     {
    390         switch (iconFileType)
    391         {
    392         case ::AppInstaller::Manifest::IconFileTypeEnum::Ico:
    393             return Microsoft::Management::Deployment::IconFileType::Ico;
    394         case ::AppInstaller::Manifest::IconFileTypeEnum::Jpeg:
    395             return Microsoft::Management::Deployment::IconFileType::Jpeg;
    396         case ::AppInstaller::Manifest::IconFileTypeEnum::Png:
    397             return Microsoft::Management::Deployment::IconFileType::Png;
    398         }
    399 
    400         return Microsoft::Management::Deployment::IconFileType::Unknown;
    401     }
    402 
    403     winrt::Microsoft::Management::Deployment::IconResolution GetDeploymentIconResolution(::AppInstaller::Manifest::IconResolutionEnum iconResolution)
    404     {
    405         switch (iconResolution)
    406         {
    407         case ::AppInstaller::Manifest::IconResolutionEnum::Custom:
    408             return Microsoft::Management::Deployment::IconResolution::Custom;
    409         case ::AppInstaller::Manifest::IconResolutionEnum::Square16:
    410             return Microsoft::Management::Deployment::IconResolution::Square16;
    411         case ::AppInstaller::Manifest::IconResolutionEnum::Square20:
    412             return Microsoft::Management::Deployment::IconResolution::Square20;
    413         case ::AppInstaller::Manifest::IconResolutionEnum::Square24:
    414             return Microsoft::Management::Deployment::IconResolution::Square24;
    415         case ::AppInstaller::Manifest::IconResolutionEnum::Square30:
    416             return Microsoft::Management::Deployment::IconResolution::Square30;
    417         case ::AppInstaller::Manifest::IconResolutionEnum::Square32:
    418             return Microsoft::Management::Deployment::IconResolution::Square32;
    419         case ::AppInstaller::Manifest::IconResolutionEnum::Square36:
    420             return Microsoft::Management::Deployment::IconResolution::Square36;
    421         case ::AppInstaller::Manifest::IconResolutionEnum::Square40:
    422             return Microsoft::Management::Deployment::IconResolution::Square40;
    423         case ::AppInstaller::Manifest::IconResolutionEnum::Square48:
    424             return Microsoft::Management::Deployment::IconResolution::Square48;
    425         case ::AppInstaller::Manifest::IconResolutionEnum::Square60:
    426             return Microsoft::Management::Deployment::IconResolution::Square60;
    427         case ::AppInstaller::Manifest::IconResolutionEnum::Square64:
    428             return Microsoft::Management::Deployment::IconResolution::Square64;
    429         case ::AppInstaller::Manifest::IconResolutionEnum::Square72:
    430             return Microsoft::Management::Deployment::IconResolution::Square72;
    431         case ::AppInstaller::Manifest::IconResolutionEnum::Square80:
    432             return Microsoft::Management::Deployment::IconResolution::Square80;
    433         case ::AppInstaller::Manifest::IconResolutionEnum::Square96:
    434             return Microsoft::Management::Deployment::IconResolution::Square96;
    435         case ::AppInstaller::Manifest::IconResolutionEnum::Square256:
    436             return Microsoft::Management::Deployment::IconResolution::Square256;
    437         }
    438 
    439         return Microsoft::Management::Deployment::IconResolution::Custom;
    440     }
    441 
    442     winrt::Microsoft::Management::Deployment::IconTheme GetDeploymentIconTheme(::AppInstaller::Manifest::IconThemeEnum iconTheme)
    443     {
    444         switch (iconTheme)
    445         {
    446         case ::AppInstaller::Manifest::IconThemeEnum::Default:
    447             return Microsoft::Management::Deployment::IconTheme::Default;
    448         case ::AppInstaller::Manifest::IconThemeEnum::Light:
    449             return Microsoft::Management::Deployment::IconTheme::Light;
    450         case ::AppInstaller::Manifest::IconThemeEnum::Dark:
    451             return Microsoft::Management::Deployment::IconTheme::Dark;
    452         case ::AppInstaller::Manifest::IconThemeEnum::HighContrast:
    453             return Microsoft::Management::Deployment::IconTheme::HighContrast;
    454         }
    455 
    456         return Microsoft::Management::Deployment::IconTheme::Unknown;
    457     }
    458 
    459     winrt::Microsoft::Management::Deployment::AuthenticationType GetDeploymentAuthenticationType(::AppInstaller::Authentication::AuthenticationType authType)
    460     {
    461         switch (authType)
    462         {
    463         case ::AppInstaller::Authentication::AuthenticationType::None:
    464             return Microsoft::Management::Deployment::AuthenticationType::None;
    465         case ::AppInstaller::Authentication::AuthenticationType::MicrosoftEntraId:
    466             return Microsoft::Management::Deployment::AuthenticationType::MicrosoftEntraId;
    467         case ::AppInstaller::Authentication::AuthenticationType::MicrosoftEntraIdForAzureBlobStorage:
    468             return Microsoft::Management::Deployment::AuthenticationType::MicrosoftEntraIdForAzureBlobStorage;
    469         }
    470 
    471         return Microsoft::Management::Deployment::AuthenticationType::Unknown;
    472     }
    473 
    474     ::AppInstaller::Authentication::AuthenticationMode GetAuthenticationMode(winrt::Microsoft::Management::Deployment::AuthenticationMode authMode)
    475     {
    476         switch (authMode)
    477         {
    478         case winrt::Microsoft::Management::Deployment::AuthenticationMode::Interactive:
    479             return ::AppInstaller::Authentication::AuthenticationMode::Interactive;
    480         case winrt::Microsoft::Management::Deployment::AuthenticationMode::SilentPreferred:
    481             return ::AppInstaller::Authentication::AuthenticationMode::SilentPreferred;
    482         case winrt::Microsoft::Management::Deployment::AuthenticationMode::Silent:
    483             return ::AppInstaller::Authentication::AuthenticationMode::Silent;
    484         }
    485 
    486         return ::AppInstaller::Authentication::AuthenticationMode::Unknown;
    487     }
    488 
    489     ::AppInstaller::Authentication::AuthenticationArguments GetAuthenticationArguments(winrt::Microsoft::Management::Deployment::AuthenticationArguments authArgs)
    490     {
    491         ::AppInstaller::Authentication::AuthenticationArguments result;
    492         result.Mode = ::AppInstaller::Authentication::AuthenticationMode::Silent; // Default to silent for com invocations.
    493 
    494         if (authArgs)
    495         {
    496             result.Mode = GetAuthenticationMode(authArgs.AuthenticationMode());
    497             result.AuthenticationAccount = ::AppInstaller::Utility::ConvertToUTF8(authArgs.AuthenticationAccount());
    498         }
    499 
    500         return result;
    501     }
    502 
    503     AddPackageCatalogStatus GetAddPackageCatalogOperationStatus(winrt::hresult hresult)
    504     {
    505         switch (hresult)
    506         {
    507         case APPINSTALLER_CLI_ERROR_AUTHENTICATION_TYPE_NOT_SUPPORTED:
    508             return AddPackageCatalogStatus::AuthenticationError;
    509         case APPINSTALLER_CLI_ERROR_SOURCE_NOT_SECURE:
    510         case APPINSTALLER_CLI_ERROR_INVALID_SOURCE_TYPE:
    511         case APPINSTALLER_CLI_ERROR_SOURCE_NOT_REMOTE:
    512         case APPINSTALLER_CLI_ERROR_SOURCE_NAME_ALREADY_EXISTS:
    513         case APPINSTALLER_CLI_ERROR_SOURCE_ARG_ALREADY_EXISTS:
    514             return AddPackageCatalogStatus::InvalidOptions;
    515         default:
    516             return HandleCommonCatalogOperationStatus<AddPackageCatalogStatus>(hresult);
    517         }
    518     }
    519 
    520     RemovePackageCatalogStatus GetRemovePackageCatalogOperationStatus(winrt::hresult hresult)
    521     {
    522         switch (hresult)
    523         {
    524         case APPINSTALLER_CLI_ERROR_SOURCE_NAME_DOES_NOT_EXIST:
    525             return RemovePackageCatalogStatus::InvalidOptions;
    526         case APPINSTALLER_CLI_ERROR_INVALID_SOURCE_TYPE:
    527             return RemovePackageCatalogStatus::CatalogError;
    528         default:
    529             return HandleCommonCatalogOperationStatus<RemovePackageCatalogStatus>(hresult);
    530         }
    531     }
    532 
    533     ::AppInstaller::Manifest::PlatformEnum GetPlatformEnum(WindowsPlatform value)
    534     {
    535         switch (value)
    536         {
    537         case WindowsPlatform::Unknown: return AppInstaller::Manifest::PlatformEnum::Unknown;
    538         case WindowsPlatform::Universal: return AppInstaller::Manifest::PlatformEnum::Universal;
    539         case WindowsPlatform::Desktop: return AppInstaller::Manifest::PlatformEnum::Desktop;
    540         case WindowsPlatform::IoT: return AppInstaller::Manifest::PlatformEnum::IoT;
    541         case WindowsPlatform::Team: return AppInstaller::Manifest::PlatformEnum::Team;
    542         case WindowsPlatform::Holographic: return AppInstaller::Manifest::PlatformEnum::Holographic;
    543         default: return AppInstaller::Manifest::PlatformEnum::Unknown;
    544         }
    545     }
    546 }