2016-03-20 04:02:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Local.Models
|
|
|
|
|
{
|
|
|
|
|
public class SpotifyUri
|
|
|
|
|
{
|
|
|
|
|
public string Base { get; internal set; }
|
|
|
|
|
public string Type { get; internal set; }
|
|
|
|
|
public string Id { get; internal set; }
|
|
|
|
|
|
2016-03-21 14:48:50 +00:00
|
|
|
|
public SpotifyUri(string uriBase, string uriType, string uriId)
|
|
|
|
|
{
|
|
|
|
|
Base = uriBase;
|
|
|
|
|
Type = uriType;
|
|
|
|
|
Id = uriId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static SpotifyUri Parse(string uri)
|
2016-03-20 04:02:15 +00:00
|
|
|
|
{
|
2016-03-31 11:08:23 +01:00
|
|
|
|
if (string.IsNullOrEmpty(uri))
|
2016-03-21 11:56:06 +00:00
|
|
|
|
throw new ArgumentNullException("Uri");
|
|
|
|
|
|
|
|
|
|
string[] props = uri.Split(':');
|
|
|
|
|
if (props.Length != 3)
|
|
|
|
|
throw new ArgumentException("Unexpected Uri");
|
|
|
|
|
|
2016-03-21 14:48:50 +00:00
|
|
|
|
return new SpotifyUri(props[0], props[1], props[2]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{Base}:{Type}:{Id}";
|
2016-03-20 04:02:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|