Background:
I’m not sure exactly how to phrase this question, so this is the example of what I’m trying to achieve:
public interface IEverythingVM : IA, IB
{
MyTypeA {get;}
MyTypeB {get;}
MyTypeC {get;}
MyTypeD {get;}
MyTypeE {get;}
MyTypeF {get;}
}
public class EverythingVM : IEverythingVM
{
// Populate everything from MyTypeA to MyTypeF
}
public interface IA
{
MyTypeA {get;}
MyTypeB {get;}
MyTypeC {get;}
}
public interface IB
{
MyTypeD {get;}
MyTypeE {get;}
MyTypeF {get;}
}
Realisation:
I was under the impression that I could do something like the following, but having written it out, it’s planely apparent why it won’t work – I’m trying to take something big, debigulate it and then rebigulate it, which is a concept so ridiculous it makes me want to laugh out loud and chortle.
{
IA varIA = new EverythingVM(param1, param2);
IB varIB = new EverythingVM(param1, param2);
var cm = new ComparisonManager(varIA, varIB);
}
public class ComparisonManager
{
public ComparisonManager(IEverythingVM varEIA, IEverythingVM varEIB)
{
// be able to acces MyTypeA, MyTypeB & MyTypeC from varEIA
// be able to acces MyTypeD, MyTypeE & MyTypeF from varEIB
}
}
Question:
Ultimately what I’m trying to achieve is that in some cases I want MyTypeA, MyTypeB & MyTypeC available in ComparisonManager, and in other cases I want MyTypeD, MyTypeE & MyTypeF available in ComparisonManager. Is there any way for me to achieve this given the current structure?
it turns out the solution was to:
Implementation: