Here's an alternative approach (we used something similar, but not sure how much it will fit your linq implementation):
Install each interface with basic functionality on the StadiumBaseClass platform, and then set the virtual properties that the implementation classes can use to: a) indicate which interfaces it supports, and b) change the default behavior as necessary.
For example, assuming the following interfaces:
public interface IBaseball { void Whatever(); } public interface IHockey { void Whatever(); } public interface IFootball { void Whatever(); } public interface IBasketball { void Whatever(); } public interface ISoccer { void Whatever(); }
Your base class will look something like this:
public class StadiumBaseClass : IBaseball, IBasketball, IHockey, IFootball, ISoccer { #region IBaseball Members public virtual bool IBaseballImplemented { get { return false; } } void IBaseball.Whatever() { // Do something } #endregion #region IBasketball Members public virtual bool IBasketballImplemented { get { return false; } } void IBasketball.Whatever() { // Do something } #endregion #region IHockey Members public virtual bool IHockeyImplemented { get { return false; } } void IHockey.Whatever() { // Do something } #endregion #region IFootball Members public virtual bool IFootballImplemented { get { return false; } } void IFootball.Whatever() { // Do something } #endregion #region ISoccer Members public virtual bool ISoccerImplemented { get { return false; } } void ISoccer.Whatever() { // Do something } #endregion }
Which would leave your individual class stadium:
class YankeeStadium : StadiumBaseClass { public override bool IBaseballImplemented { get { return true; } } public override bool IHockeyImplemented { get { return true; } } public override bool IFootballImplemented { get { return true; } } }
source share