wabbajack/Wabbajack.App/Converters/AbsoultePathBindingConverter.cs
2021-10-23 10:51:17 -06:00

32 lines
868 B
C#

using System;
using ReactiveUI;
using Wabbajack.Paths;
namespace Wabbajack.App.Converters;
public class AbsoultePathBindingConverter : IBindingTypeConverter
{
public int GetAffinityForObjects(Type fromType, Type toType)
{
if (fromType == typeof(string) && toType == typeof(AbsolutePath) ||
fromType == typeof(AbsolutePath) && toType == typeof(string))
return 100;
return 0;
}
public bool TryConvert(object? from, Type toType, object? conversionHint, out object? result)
{
switch (from)
{
case string s:
result = (AbsolutePath) s;
return true;
case AbsolutePath ap:
result = ap.ToString();
return true;
default:
result = null;
return false;
}
}
}