Windows-powershell / PowerShell-master /src /Microsoft.Management.UI.Internal /ManagementList /Common /IsEqualConverter.cs
| // Copyright (c) Microsoft Corporation. | |
| // Licensed under the MIT License. | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Diagnostics.CodeAnalysis; | |
| using System.Text; | |
| using System.Windows; | |
| using System.Windows.Data; | |
| namespace Microsoft.Management.UI.Internal | |
| { | |
| /// <summary> | |
| /// Takes two objects and determines whether they are equal. | |
| /// </summary> | |
| [] | |
| public class IsEqualConverter : IMultiValueConverter | |
| { | |
| /// <summary> | |
| /// Takes two items and determines whether they are equal. | |
| /// </summary> | |
| /// <param name="values"> | |
| /// Two objects of any type. | |
| /// </param> | |
| /// <param name="targetType">The parameter is not used.</param> | |
| /// <param name="parameter">The parameter is not used.</param> | |
| /// <param name="culture">The parameter is not used.</param> | |
| /// <returns> | |
| /// True if-and-only-if the two objects are equal per Object.Equals(). | |
| /// Null is equal only to null. | |
| /// </returns> | |
| public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |
| { | |
| ArgumentNullException.ThrowIfNull(values); | |
| if (values.Length != 2) | |
| { | |
| throw new ArgumentException("Two values expected", "values"); | |
| } | |
| object item1 = values[0]; | |
| object item2 = values[1]; | |
| if (item1 == null) | |
| { | |
| return item2 == null; | |
| } | |
| if (item2 == null) | |
| { | |
| return false; | |
| } | |
| bool equal = item1.Equals(item2); | |
| return equal; | |
| } | |
| /// <summary> | |
| /// This method is not used. | |
| /// </summary> | |
| /// <param name="value">The parameter is not used.</param> | |
| /// <param name="targetTypes">The parameter is not used.</param> | |
| /// <param name="parameter">The parameter is not used.</param> | |
| /// <param name="culture">The parameter is not used.</param> | |
| /// <returns>The parameter is not used.</returns> | |
| public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) | |
| { | |
| throw new NotImplementedException(); | |
| } | |
| } | |
| } | |