-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Winget client rest source parsing for 1.7 manifest (#4155)
- Loading branch information
Showing
8 changed files
with
490 additions
and
11 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/AppInstallerRepositoryCore/Rest/Schema/1_7/Json/ManifestDeserializer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#pragma once | ||
#include "Rest/Schema/1_6/Json/ManifestDeserializer.h" | ||
|
||
namespace AppInstaller::Repository::Rest::Schema::V1_7::Json | ||
{ | ||
// Manifest Deserializer. | ||
struct ManifestDeserializer : public V1_6::Json::ManifestDeserializer | ||
{ | ||
protected: | ||
|
||
std::optional<Manifest::ManifestInstaller> DeserializeInstaller(const web::json::value& installerJsonObject) const override; | ||
|
||
std::map<Manifest::InstallerSwitchType, Manifest::string_t> DeserializeInstallerSwitches(const web::json::value& installerSwitchesJsonObject) const override; | ||
|
||
Manifest::ManifestVer GetManifestVersion() const override; | ||
}; | ||
} |
50 changes: 50 additions & 0 deletions
50
src/AppInstallerRepositoryCore/Rest/Schema/1_7/Json/ManifestDeserializer_1_7.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#include "pch.h" | ||
#include "ManifestDeserializer.h" | ||
#include <winget/JsonUtil.h> | ||
|
||
using namespace AppInstaller::Manifest; | ||
|
||
namespace AppInstaller::Repository::Rest::Schema::V1_7::Json | ||
{ | ||
namespace | ||
{ | ||
// Installer | ||
constexpr std::string_view InstallerSwitchRepair = "Repair"sv; | ||
constexpr std::string_view RepairBehavior = "RepairBehavior"sv; | ||
} | ||
|
||
std::optional<Manifest::ManifestInstaller> ManifestDeserializer::DeserializeInstaller(const web::json::value& installerJsonObject) const | ||
{ | ||
auto result = V1_6::Json::ManifestDeserializer::DeserializeInstaller(installerJsonObject); | ||
|
||
if (result) | ||
{ | ||
auto& installer = result.value(); | ||
|
||
installer.RepairBehavior = Manifest::ConvertToRepairBehaviorEnum(JSON::GetRawStringValueFromJsonNode(installerJsonObject, JSON::GetUtilityString(RepairBehavior)).value_or("")); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
std::map<Manifest::InstallerSwitchType, Manifest::string_t> ManifestDeserializer::DeserializeInstallerSwitches(const web::json::value& installerSwitchesJsonObject) const | ||
{ | ||
auto installerSwitches = V1_6::Json::ManifestDeserializer::DeserializeInstallerSwitches(installerSwitchesJsonObject); | ||
|
||
auto repairValue = JSON::GetRawStringValueFromJsonNode(installerSwitchesJsonObject, JSON::GetUtilityString(InstallerSwitchRepair)); | ||
|
||
if (JSON::IsValidNonEmptyStringValue(repairValue)) | ||
{ | ||
installerSwitches[Manifest::InstallerSwitchType::Repair] = repairValue.value(); | ||
} | ||
|
||
return installerSwitches; | ||
} | ||
|
||
Manifest::ManifestVer ManifestDeserializer::GetManifestVersion() const | ||
{ | ||
return Manifest::s_ManifestVersionV1_7; | ||
} | ||
} |