To abstract all the information about the image we want to display, we'll create a class that encapsulates this information. There isn't much information in our Picture class, but it is good coding practice to do this. Proceed as follows:
- Create a new class called Picture in the Utils folder.
- Add the following code to the class:
public class Picture
{
public Uri Uri { get; set; }
public string Description { get; set; }
public Picture()
{
Uri = new Uri($"https://picsum.photos/400/400/?random&ts=
{DateTime.Now.Ticks}");
var generator = new DescriptionGenerator();
Description = generator.Generate();
}
}
The Picture class has the following two public properties:
- The Uniform Resource Identifier (URI) of an image exposed as the Uri property, which points to its location on the internet
- A description of that image exposed as the Description property.
In the constructor, we create a new URI, which points to a public source...