I have an abstract class:
abstract class AbstractDataExport { public string name; public abstract bool ExportData(); }
I have classes that are derived from AbstractDataExport:
class XmlExport : AbstractDataExport { new public string name = "XmlExporter"; public override bool ExportData() { ... } } class CsvExport : AbstractDataExport { new public string name = "CsvExporter"; public override bool ExportData() { ... } }
Is it possible to do something like this? (Pseudo code :)
foreach (Implementation imp in Reflection.GetInheritedClasses(AbstractDataExport) { AbstractDataExport derivedClass = Implementation.CallConstructor(); Console.WriteLine(derivedClass.name) }
with an exit like
CsvExporter XmlExporter
?
The idea is to simply create a new class that is derived from AbstractDataExport, so I can automatically execute all implementations and add, for example, names to the drop-down list. I just want to encode a derived class without changing anything else in the project, recompile, bingo!
If you have alternative solutions: tell em.
thank
inheritance reflection c #
trampi Mar 23 2018-11-21T00: 00Z
source share