Spotify.NET/SpotifyAPI.Web/Util/URIParameterFormatProvider.cs
2020-05-02 13:04:26 +02:00

28 lines
643 B
C#

using System.Web;
using System;
namespace SpotifyAPI.Web
{
public class URIParameterFormatProvider : IFormatProvider
{
private readonly URIParameterFormatter _formatter;
public URIParameterFormatProvider()
{
_formatter = new URIParameterFormatter();
}
public object GetFormat(Type formatType)
{
return formatType == typeof(ICustomFormatter) ? _formatter : null;
}
public class URIParameterFormatter : ICustomFormatter
{
public string Format(string format, object arg, IFormatProvider formatProvider)
{
return HttpUtility.UrlEncode(arg.ToString());
}
}
}
}