Is it possible to define an interface where one of the objects is a list of another interface?
I have two EF objects:
=====
class ImageType1
{
string Id
string Name
List<ImageType1Size> Sizes
}
class ImageType1Size
{
string Id
int Width
int Height
}
class ImageType2
{
string UserId
string ImageId
string Name
List<ImageType2Size> Sizes
}
class ImageType2Size
{
string UserId
string ImageId
int Width
int Height
}
=====
For each of the image size classes, all of the properties are keys (just a side note).
Now, what I want to do is create the following two interfaces:
=====
interface IImage
{
string Name
List<ImageSize> Sizes
}
interface IImageSize
{
int Width
int Height
}
=====
In my project, I have created partials for ImageType1, ImageType1Size, ImageType2, and ImageType2Size, each using the respective interface.
I’m getting an error in trying to cast the Sizes property in ImageType1 and ImageType2 to use the interface IImageSize.
=====
Is this possible to do? If I’m not clear please let me know and I’ll rephrase the question.
Thanks!
You might want to consider generics here:
Alternatively, this would work:
It depends on what works best for how you operate on the data.