Spotify.NET/SpotifyAPI.Web/Util/URIParameterFormatProvider.cs
2020-05-01 20:05:28 +02:00

30 lines
659 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)
{
if (formatType == typeof(ICustomFormatter))
return _formatter;
return null;
}
class URIParameterFormatter : ICustomFormatter
{
public string Format(string format, object arg, IFormatProvider formatProvider)
{
return HttpUtility.UrlEncode(arg.ToString());
}
}
}
}