mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
33 lines
971 B
C#
33 lines
971 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;
|
|
}
|
|
}
|
|
}
|
|
} |