Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
JoinStrings.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.Collections.Generic;
5 using System.Globalization;
6 
7 namespace SiliconStudio.Presentation.ValueConverters
8 {
9  /// <summary>
10  /// This value converter will join an enumerable of strings with the separator given as parameter (or using a single space character as separator
11  /// if the parameter is null).
12  /// </summary>
13  public class JoinStrings : ValueConverterBase<JoinStrings>
14  {
15  /// <inheritdoc/>
16  public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17  {
18  var strings = (IEnumerable<string>)value;
19  var separator = (string)parameter;
20  return string.Join(separator ?? " ", strings);
21  }
22 
23  /// <inheritdoc/>
24  public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
25  {
26  var str = (string)value;
27  var separator = (string)parameter;
28  return str.Split(new[] { separator ?? " "}, StringSplitOptions.None);
29  }
30  }
31 }
override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Definition: JoinStrings.cs:24
This value converter will join an enumerable of strings with the separator given as parameter (or usi...
Definition: JoinStrings.cs:13
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Definition: JoinStrings.cs:16