Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
IsEqualToParam.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Globalization;
5 
6 namespace SiliconStudio.Presentation.ValueConverters
7 {
8  /// <summary>
9  /// This converter will convert an object to a boolean. If the given value is equal (or reference-equal for non-value type) to the parameter, it will
10  /// return <c>true</c>. Otherwise, it will return <c>false</c>.
11  /// </summary>
12  public class IsEqualToParam : OneWayValueConverter<IsEqualToParam>
13  {
14  /// <inheritdoc/>
15  public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16  {
17  if (value == null)
18  return parameter == null;
19 
20  bool useEquals = value.GetType().IsValueType || value is string;
21  bool result = useEquals ? Equals(value, parameter) : ReferenceEquals(value, parameter);
22  return result;
23  }
24  }
25 }
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
This converter will convert an object to a boolean. If the given value is equal (or reference-equal f...