I have a class from an external library that I need to extend into the antoher class. In addition, extensions must remain reusable, as I need them in other places.
Since neither mixins nor multiple inheritance are supported in C #, what is the general way to solve this problem?
namespace ExtLib
{
public class Properties
{
public virtual int fieldN { get; set; }
}
}
namespace MyLib
{
public class Extensions
{
public virtual int fieldM { get; set; }
}
}
namespace MyProject
{
public class MyModel
{
}
public class MyOtherModel
{
}
}
I know that a decision can be an interface IExtensions
, but it leads to a lot of duplication, because the number of fields Extensions
and Properties
pretty large (and they vary greatly in the development phase).
Are there any recommendations?
source
share