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

28 lines
644 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();
}
public object GetFormat(Type formatType)
{
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());
}
}
}
}