using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; namespace HeuristicLab.OKB.Cockpit.Query { public class TypeNameConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return FormatType(value); } public static object FormatType(object value) { Type type = value as Type; if (type == null) return "none"; StringBuilder sb = new StringBuilder(); if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) { sb.Append('?'); type = type.GetGenericArguments()[0]; } if (type == typeof(Int32)) sb.Append("int"); if (type == typeof(Double)) sb.Append("double"); if (type == typeof(String)) sb.Append("string"); if (type == typeof(Guid)) sb.Append("Guid"); if (type == typeof(DateTime)) sb.Append("DateTime"); return sb.ToString(); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } }