Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
UnderlyingType.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 a <see cref="Nullable"/> type to its underlying type. If the type is not nullable, it returns the type itself.
10  /// </summary>
11  public class UnderlyingType : OneWayValueConverter<UnderlyingType>
12  {
13  /// <inheritdoc/>
14  public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15  {
16  var type = value as Type;
17  if (type == null)
18  {
19  throw new ArgumentException("The object passed to this value converter is not a type.");
20  }
21  return Nullable.GetUnderlyingType(type) ?? value;
22  }
23  }
24 }
This converter convert a Nullable type to its underlying type. If the type is not nullable...
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)