Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
XOrMultiConverter.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 using System.Linq;
6 
7 namespace SiliconStudio.Presentation.ValueConverters
8 {
9  public class XOrMultiConverter : OneWayMultiValueConverter<XOrMultiConverter>
10  {
11  public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
12  {
13  if (values.Length < 2)
14  throw new InvalidOperationException("This multi converter must be invoked with at least two elements");
15 
16  return values.Skip(1).Aggregate((bool)values[0], (current, value) => current ^ (bool)value);
17  }
18  }
19 }
override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)