Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ObjectToTypeName.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 convert any object to a string representing the name of its type (without assembly or namespace qualification).
10  /// It accepts null and will convert it to a string representation of null.
11  /// </summary>
12  /// <seealso cref="ObjectToFullTypeName"/>
13  /// <seealso cref="ObjectToType"/>
14  public class ObjectToTypeName : OneWayValueConverter<ObjectToTypeName>
15  {
16  /// <summary>
17  /// The string representation of the type of a null object
18  /// </summary>
19  public const string NullObjectType = "(null)";
20 
21  /// <inheritdoc/>
22  public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
23  {
24  return value == null ? NullObjectType : value.GetType().Name;
25  }
26  }
27 }
This converter convert any object to a string representing the name of its type (without assembly or ...
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)