mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-18 09:35:48 +00:00
source code checkin
This commit is contained in:
parent
5f8fb2c825
commit
7e57b72e35
675 changed files with 168433 additions and 0 deletions
32
src/ServerManager.Common/Converters/EnumConverter.cs
Normal file
32
src/ServerManager.Common/Converters/EnumConverter.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Common.Converters
|
||||
{
|
||||
public class EnumConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null || parameter == null)
|
||||
return false;
|
||||
|
||||
string checkValue = value.ToString();
|
||||
string targetValue = parameter.ToString();
|
||||
return checkValue.Equals(targetValue, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null || parameter == null)
|
||||
return null;
|
||||
|
||||
bool useValue = (bool)value;
|
||||
string targetValue = parameter.ToString();
|
||||
if (useValue)
|
||||
return Enum.Parse(targetType, targetValue);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue