Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
917 B

using System;
using System.Globalization;
using Avalonia.Data.Converters;
namespace StabilityMatrix.Avalonia.Converters;
/// <summary>
/// Converts an Uri to a string, excluding leading protocol and trailing slashes
/// </summary>
public class UriStringConverter : IValueConverter
{
/// <inheritdoc />
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is Uri uri)
{
return (
uri.Host
+ (uri.IsDefaultPort ? "" : $":{uri.Port}")
+ uri.PathAndQuery
+ uri.Fragment
).TrimEnd('/');
}
return null;
}
/// <inheritdoc />
public object ConvertBack(
object? value,
Type targetType,
object? parameter,
CultureInfo culture
)
{
throw new NotImplementedException();
}
}