forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
168 additions
and
27 deletions.
There are no files selected for viewing
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
62 changes: 62 additions & 0 deletions
62
src/Microsoft.Management.Configuration.Processor/Extensions/DictionaryExtensions.cs
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,62 @@ | ||
// ----------------------------------------------------------------------------- | ||
// <copyright file="DictionaryExtensions.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. Licensed under the MIT License. | ||
// </copyright> | ||
// ----------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.Management.Configuration.Processor.Extensions | ||
{ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Windows.Foundation.Collections; | ||
|
||
/// <summary> | ||
/// Extensions for dictionaries. | ||
/// </summary> | ||
internal static class DictionaryExtensions | ||
{ | ||
/// <summary> | ||
/// Performs a deep compare of the dictionaries. | ||
/// </summary> | ||
/// <param name="first">First dictionary.</param> | ||
/// <param name="second">Second dictionary.</param> | ||
/// <returns>Whether the two dictionaries equal.</returns> | ||
internal static bool ContentEquals(this IDictionary<string, string> first, IDictionary<string, string> second) | ||
{ | ||
if (first.Count != second.Count) | ||
{ | ||
return false; | ||
} | ||
|
||
foreach (var keyValuePair in first) | ||
{ | ||
string key = keyValuePair.Key; | ||
if (!second.ContainsKey(key)) | ||
{ | ||
return false; | ||
} | ||
|
||
var firstValue = keyValuePair.Value; | ||
var secondValue = second[key]; | ||
|
||
// Empty value check. | ||
if (firstValue == null && secondValue == null) | ||
{ | ||
continue; | ||
} | ||
else if (firstValue == null || secondValue == null) | ||
{ | ||
return false; | ||
} | ||
|
||
if (firstValue != secondValue) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
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
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