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
|
|
|
{
|
2020-05-02 12:04:26 +01:00
|
|
|
return formatType == typeof(ICustomFormatter) ? _formatter : null;
|
2020-05-01 19:05:28 +01:00
|
|
|
}
|
|
|
|
|
2020-05-05 14:30:00 +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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|