using System;
using System.Globalization;
using System.Windows.Data;
using Crysome.Common.Model;
using Crysome.Server.Resources;

namespace Crysome.Server.Converters;

[ValueConversion(typeof(FileType), typeof(string))]
public class FileTypeConverter : IValueConverter
{
	public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Invalid comparison between Unknown and I4
		if ((int)(FileType)value != 1)
		{
			return Strings.FileType_Folder;
		}
		return Strings.FileType_File;
	}

	public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
	{
		return (object)(FileType)(((string)value == Strings.FileType_File) ? 1 : 0);
	}
}
