Spotify.NET/SpotifyAPI.Web/Util/URIParameterFormatProvider.cs

28 lines
645 B
C#
Raw Normal View History

2020-05-01 19:05:28 +01:00
using System.Web;
using System;
namespace SpotifyAPI.Web
{
public class URIParameterFormatProvider : IFormatProvider
{
private readonly URIParameterFormatter _formatter;
public URIParameterFormatProvider()
{
_formatter = new URIParameterFormatter();
}
2020-05-25 17:00:38 +01:00
public object? GetFormat(Type formatType)
2020-05-01 19:05:28 +01:00
{
return formatType == typeof(ICustomFormatter) ? _formatter : null;
2020-05-01 19:05:28 +01:00
}
private class URIParameterFormatter : ICustomFormatter
2020-05-01 19:05:28 +01:00
{
public string Format(string format, object arg, IFormatProvider formatProvider)
{
return HttpUtility.UrlEncode(arg.ToString());
}
}
}
}