the most appropriate answer here is either to implement a common interface, or to override a virtual method from a common base class, and use polymorphism to provide an implementation (from various implementation classes) at runtime. Then your method will look like this:
(blah.Handle).AssociatedFeature = requirementTemplate.GetAssociatedFeature();
If the list is not exclusive (i.e. there are other implementations), then:
var feature = requirementTemplate as IHasAssociatedFeature; if(feature != null) { (blah.Handle).AssociatedFeature = feature.GetAssociatedFeature(); }
you can do similar things on the left side too, or convey this in context:
var feature = requirementTemplate as IHasAssociatedFeature; if(feature != null) { feature.SetAssociatedFeature(blah); }
(if necessary)
Another non-standard approach is switch on the listing here:
switch(requirementTemplate.FeatureType) { case ... }
One good thing about this is that it can be either specific to a specific or instance specific.
source share