I have following class:
public class ContentVideoType
{
public string Title { get; set; }
public string GetThumbnail { get; set; }
}
When creating an instance of this class, I want to assign a custom getter for GetThumbnail. I don't know how it is called but as far as I know the code must be like:
var youtube = new ContentVideoType
{
Title = "Youtube",
GetThumbnail = (x) => { return $"https://i.ytimg.com/vi/{x}/mqdefault.jpg"; }
};
var vimeo = new ContentVideoType
{
Title = "Vimeo",
GetThumbnail = (x) => GetVimeoImage(x)
};
For Viemo for example I need to call following function for GetThumbnail:
public static string GetVimeoImage(string vimeoId)
{
string result = String.Empty;
try
{
XmlDocument doc = new XmlDocument();
doc.Load("http://vimeo.com/api/v2/video/" + vimeoId + ".xml");
XmlElement root = doc.DocumentElement;
result = root.FirstChild.SelectSingleNode("thumbnail_medium").ChildNodes[0].Value;
}
catch
{
//cat with cheese on it's face fail
}
return result;
}