Hi,
I'm currently rewriting a program so that it can be modularised and it is progressing well,
but now I have a problem which I'm having problems with:
Lets say I have two projects.
The Main project with class main and
another project Extention with class ext.
Now assume 'class ext' is an extended version of a Dictionary object and it is used in many other objects.
So the project Extention cannot depend on the Main project.
But the Main Project cannot depend on the Extention Project either since I want to make the Main Project modular,
so basically I want the possibillity to either exchange the Extention Project with another Project,
which implements the same needed methods or even to not include it, without the Main Project throwing errors.
I've tried creating identical Interfaces in both Projects and
then cast the one Interface into the other but as expected it threw an exception.
An example to better understand what I'm trying to do:
[CSharp]//Project Main
class Main{
iExt dict;
private iExt GetExtention(){
dict = (iExt)[Retrieve class Ext from Project Extention']
}
}
interface iExt{
object GetValue();
}
//Project Extention
class Ext : iExt{
}
interface iExt{
object GetValue();
}
//No dependencies set between the two Projects
//Project Extention can be replaced by another Project which implements iExt
//If there is no Project which implements iExt the Main Project shouldn't throw an error[/CSharp]
Is there a way to pull this off, or is it impossible/to complex to do?
I'm currently rewriting a program so that it can be modularised and it is progressing well,
but now I have a problem which I'm having problems with:
Lets say I have two projects.
The Main project with class main and
another project Extention with class ext.
Now assume 'class ext' is an extended version of a Dictionary object and it is used in many other objects.
So the project Extention cannot depend on the Main project.
But the Main Project cannot depend on the Extention Project either since I want to make the Main Project modular,
so basically I want the possibillity to either exchange the Extention Project with another Project,
which implements the same needed methods or even to not include it, without the Main Project throwing errors.
I've tried creating identical Interfaces in both Projects and
then cast the one Interface into the other but as expected it threw an exception.
An example to better understand what I'm trying to do:
[CSharp]//Project Main
class Main{
iExt dict;
private iExt GetExtention(){
dict = (iExt)[Retrieve class Ext from Project Extention']
}
}
interface iExt{
object GetValue();
}
//Project Extention
class Ext : iExt{
}
interface iExt{
object GetValue();
}
//No dependencies set between the two Projects
//Project Extention can be replaced by another Project which implements iExt
//If there is no Project which implements iExt the Main Project shouldn't throw an error[/CSharp]
Is there a way to pull this off, or is it impossible/to complex to do?