I'm expanding on my previous question, which was solved. How to call Method's Class Name dynamically?
interface IVideoCodec
works with void
Methods successfully, but it is not working with List
.
VP8
Class
gives the error 'VP8' does not implement interface member 'Controls.IVideoCodec.test'
File: VideoControls.cs
namespace Controls.Video
{
public class Controls
{
private static Dictionary<string, IVideoCodec> _vCodecClass;
private static void InitializeCodecs()
{
_vCodecClass = new Dictionary<string, IVideoCodec> {
{ "VP8", new Codec.VP8() },
{ "VP9", new Codec.VP9() },
{ "x264", new Codec.x264() },
{ "x265", new Codec.x265() }
};
}
public interface IVideoCodec
{
List<string> test { get; set; } // doesn't work
//void Example(); // works
}
public static void SetControls(string codec_SelectedItem)
{
InitializeCodecs();
List<string> example = _vCodecClass[codec_SelectedItem].test; // equal to Codec.VP8.test
//_vCodecClass[codec_SelectedItem].Example(); // equal to Codec.VP8.Example() // works
}
}
}
File: VP8.cs
namespace Controls.Video.Codec
{
public class VP8 : Controls.IVideoCodec // <-- Gives Error
{
public List<string> test = new List<string>()
{
"1",
"2",
"3"
};
public void Example()
{
//...
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…