Plug-in Architecture To Work in WinForms MVC + WPF MVVM + ASP.Net MVC + Mobile (Xamarin MVC/PhoneGap MVC) + Win 10 Universal App MVC
This is my attempt to implement a general plugin system to work in multiple platforms and multiple technologies, with the main intent is to increase shared projects to the max, over those platforms.
This is the first draft, and I will be going back and forth in it, while I implement it, till it gets fully functional, so it might change while it gets implemented>
I searched the internet to find a suitable Plug-in architecture, that’s general enough and not too complex, to work with multiple technologies/platforms, mainly:
- WinForms MVC
- WPF MVVM
- ASP.Net MVC
- Mobile (Xamarin/PhoneGap) MVC
- Win 10 Universal App MVC
As can be seen in these articles:
And after a lot of reading for several days, I decided to go with my own architecture. And decided to make it as an article in my blog and in codeproject.com, and later on, in github.com, for sharing and collaboration with the community, to perfect it, and make it general enough for all, and to increase the sharing and benefit from the larger more beautiful minds out there, so please comment.
this article can be seen in codeproject:
I quote what MSDN said about the need for a Plug-in system:
- To extend an application’s functionality without the need to re-compile and distribute it to customers.
- To add functionality without requiring access to the original source code.
- The business rules for the application change frequently or new rules are added frequently.
And I Add my own:
- Faster compilation time and smaller solutions as each plug-in will need only small number of references to other projects.
- Maximize reuse of the main Business functionality over multiple UI/OS- platforms Technologies.
- Simplify each project, to the maximum extent.
- Help Fellow developers to speed development on all platforms.
- Unity IoC: https://unity.codeplex.com/
- Enterprise Library Logging block hidden behind the iLogger: https://entlib.codeplex.com/
- Local DB: SQL Server Local DB/ SQLite: https://www.mssqltips.com/sqlservertip/2694/getting-started-with-sql-server-2012-express-localdb
- or https://www.sqlite.org
- Server DB: SQL Server Express: https://www.microsoft.com/en-us/download/details.aspx?id=30438
- URF – Unit of Work & (extensible/generic) Repositories Framework: https://genericunitofworkandrepositories.codeplex.com
- Entity framework 7: https://github.com/aspnet/EntityFramework
- EntityFramework Reverse POCO Code First Generator, for fast POCO generation from the database: https://efreversepoco.codeplex.com
- Modelling of Objects + Database: SAP Sybase PowerDesigner: http://www.sap.com/pc/tech/database/software/model-driven-architecture/index.html
- and you can download the Sybase PD Viewer: https://global.sap.com/campaign/ne/sybase/powerdesigner16_ea/index.epx?kNtBzmUK9zU
The main architecture
|- ASP.Net MVC
|- Win 10 Universal App
Plugin\WinForms\MainUI \ MainForm
Plugin\WinForms\MainUI \ MsgBox
Services\DBLocal Previously DBInstance
UserA. Configuration.Lingual_Secondary= French Lingual Plugin.dll
Plugin\Services\ Authentication \SimpleUserAuthentication
Services\Object Management: UIFormViewManager
Services\Object Management\ UIComposableManager
Services\Object Management\ CommandManager
This will have all information about the POCO properties and their types, and linkes to other POCOs, maybe validations.
The Layers from POCO classes to UI classes:
These will implement the MVC pattern/Repository pattern.
This will have the business classes, and they will inherit from the Repository.Pattern.Ef6.Entity class, which implements the IObjectState interface for managing the POCO object state, and will all implement the INotifyPropertyChanged, so it will notify who uses it, of any internal changes, and IValidatableObject for making the POCO validate itself, by calling a method in the “Validation” project, that will search the DB for that POCO validations and uses them to validate it.
Where each main category will have its own project, like: PersonPOCO, InvoicePOCO.
This will have the mapping for the Entity framework 7 configurations of all POCO classes.
Where each main category will have its own project, like: PersonDAL, InvoiceDAL.
This will be the mediator between using Linq on the DAL layer, and upper layers, so it will hide the implementation details from them.
Where each main category will have its own project, like: PersonRepository, InvoiceRepository.
As seen here:
Model Layer/Controller Layer
I will ease things up, and relate to:
This will be implemented in plug-ins, so we can have the app work in multiple platforms
Like Plugin\WinForms\PersonUI, InvoiceUI
Currently I am thinking of using SQL Server, for app persistence.
The above is the directory structure of the architecture.
Code will be published here and in github.com
Points of Interest
Further study and comments are welcomed.
Comments/Ideas/Fixes in all the above are welcomed.
And other things to brain storm are:
Event engine/Observer Engine/Rx Engine
An engine that will facilitate plug-ability in actions and events in all or most layers.
There are the following questions that i need to have answers for:
Q1: should i Use GUID as primary key for some tables, to minimize conflicts when upgrading to new versions?
My answers to some questions asked:
Other Q1: why not use MEF?
A1: I prefer to have all my classes in their pure POCO style, and not adorn them with specifics of other tools like MEF, so that’s why I am using a DI-IoC container, to manipulate them from outside, not from inside.
v0.5.1 Tried to fix the pictures of the article + added “Other Q1”.
v0.5 creating the main architecture.