How to create a loosely coupled hot-swappable architecture?

I am interested in creating a desktop application consisting of modules, so the source code of these modules is embedded in the application itself, which allows the user to edit the application as it starts and use the updated modules without restarting the application. Can anyone suggest a good architecture for this?

I want to use Microsoft.Net and C # for this. DLR is not an option.

Thank!

+3
source share
3 answers

It is not easy to propose a good architecture for this in a short publication.

(), , /. Execute.

Wrapper-Class , :

  • , ,
  • ,
  • ,

- , -. , , Shell Execute .

" ", : http://www.west-wind.com/presentations/dynamicCode/DynamicCode.htm

+2

, , , ...

System.Reflection.Emit .

, AppDomains, .

- , , AppDomain.

0

, , , , - .

Injection Dependency , , X Y , X , X, , . Y.

Injection Dependency. - .

wahy (, , ) - . , . , . . GUID. , . ++ ( #) :

std::map<std::string,IInterface> appInterfaces;
appInterfaces["database"] = new OracleDatabaseModule();
appInterfaces["userinterface"] = new VistaStyleUserInterface();

, . , , . .

MyModule::someMethod()
{
IDatabaseInterface *dbInterface = dynamic_cast<IDatabaseInterface *>(appInterfaces["database"]);
dbInterface->executeQuery(...);
}

If you want to change the implementation of the interface in the application, you can simply change the registry entry, for example:

IInterface *iface = appInterfaces["database"];
if (iface) delete iface;
appInterface["database"] = new SqlServerDatabaseInterface();
-1
source

Source: https://habr.com/ru/post/1772441/


All Articles