Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ToDouble.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 using SiliconStudio.Core.Reflection;
7 
8 namespace SiliconStudio.Presentation.ValueConverters
9 {
10  /// <summary>
11  /// This value converter will convert any numeric value to double. <see cref="ConvertBack"/> is supported and
12  /// will convert the value to the target if it is numeric, otherwise it returns the value as-is.
13  /// </summary>
14  public class ToDouble : ValueConverterBase<ToDouble>
15  {
16  /// <inheritdoc/>
17  public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
18  {
19  return typeof(double).CastToNumericType(value);
20  }
21 
22  /// <inheritdoc/>
23  public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24  {
25  return !targetType.IsNumeric() ? value : targetType.CastToNumericType(value);
26  }
27  }
28 }
override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Definition: ToDouble.cs:23
This value converter will convert any numeric value to double. ConvertBack is supported and will conv...
Definition: ToDouble.cs:14
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Definition: ToDouble.cs:17