Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ObjectToBool.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 value, returning <c>false</c> if the object is equal to null, <c>true</c> otherwise.
10  /// </summary>
11  /// <remarks>Value types are always non-null and therefore always returns true.</remarks>
12  public class ObjectToBool : OneWayValueConverter<ObjectToBool>
13  {
14  /// <inheritdoc/>
15  public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16  {
17  if (value != null && value.GetType().IsValueType)
18  return true;
19  return value != null;
20  }
21  }
22 }
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Definition: ObjectToBool.cs:15
This converter will convert an object to a boolean value, returning false if the object is equal to n...
Definition: ObjectToBool.cs:12