-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encoding/Decoding AppNotificationBuilder arguments (#2805)
* Encode arguments * Argument encode/decode * Fix merge issues * Add Decode unit test * Use regex_replace instead * Address nits * Simplify encoding * Added XML escape encodings, need to improve Decode efficiency * Implement efficient decode * Update APITests.cpp * Add unit tests and encode all custom strings Co-authored-by: eric langlois <email@ericlanglois.com>
- Loading branch information
Showing
16 changed files
with
369 additions
and
141 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
dev/AppNotifications/AppNotificationActivatedEventArgs.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,43 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#include "pch.h" | ||
#include "AppNotificationActivatedEventArgs.h" | ||
#include "Microsoft.Windows.AppNotifications.AppNotificationActivatedEventArgs.g.cpp" | ||
#include "AppNotificationBuilder/AppNotificationBuilderUtility.h" | ||
|
||
namespace winrt::Microsoft::Windows::AppNotifications::implementation | ||
{ | ||
winrt::Windows::Foundation::Collections::IMap<hstring, hstring> AppNotificationActivatedEventArgs::DecodeArguments(std::wstring arguments) | ||
{ | ||
auto result{ winrt::single_threaded_map<winrt::hstring, winrt::hstring>() }; | ||
|
||
std::vector<std::wstring> pairs{}; | ||
size_t pos{ 0 }; | ||
|
||
// Separate the key/value pairs by ';' as the delimiter | ||
while ((pos = arguments.find(L';')) != std::wstring::npos) | ||
{ | ||
pairs.push_back(arguments.substr(0, pos)); | ||
arguments.erase(0, pos + 1); | ||
} | ||
|
||
// Need to push back final string | ||
pairs.push_back(arguments); | ||
|
||
for (auto pair : pairs) | ||
{ | ||
// Get the key/value individual values separated by '=' | ||
pos = pair.find(L'='); | ||
if (pos == std::wstring::npos) | ||
{ | ||
result.Insert(Decode(pair).c_str(), L""); | ||
} | ||
else | ||
{ | ||
result.Insert(Decode(pair.substr(0, pos)).c_str(), Decode(pair.substr(pos + 1)).c_str()); | ||
} | ||
} | ||
return result; | ||
} | ||
} |
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
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
Oops, something went wrong.