This doesnt really have a right or wrong answer and I am just looking for ideas, opinions or other experiance.
I want to do this in c#.
This isnt exactly what Im trying to do but it makes a better example and I can extrapolate from it.
Lets say I wanted to write a simple console app to decompress files.
you could do (ish) NOTE: This is far simpler than my real program.
main
{
switch(algo)
{
case "zip":
zip();
case "rar":
rar();
}
byte[] zip()
{
blah;
}
etc. etc.
}
Now ignoring inheritance / interfaces etc. this is too hardcoded.
Lets say I wanted to do this but my main console program had no concept of what its decoding it just needs the same input / output methods etc.
its just:
Interface Decode {...........................................
main
{
make a file whatever < byte[] Decode something thats passed to me();
}
but the trick is the decode part is done by code written and compiled separately and post the main program.
folder structure:
\MyMain.exe (arguments passed as to what to decode)
\Decoders\rardecode.dll
or rardecode.obj (maybe)
or rardecode.cs(compiled as needed)
zipdecode.dll
or zipdecode.obj .....
but the idea is anything can be added to the decode directory (in the same language c#), its compiled seperately (or not) (like plugins) following some kind of Interface.
Are there any patterns specific to this idea and is there a simple way to do this in c# are am I going to have to write some sort of object loader.
Its easy to do this with inheritance in the main code but its the plugin part thats important. After a little Googling I cannot put into words a simple way to search for ideas.
Hopefully all that makes sense.
Aucun commentaire:
Enregistrer un commentaire