Designing Application that can accept add ins
Like there are many Applications which are just basic but you can have install add-ins for it which extends its functionality in that Application. For example:
Fire Bug in Mozilla Firefox.
How do they design such applications and how does the application accept the module and how can it automatically integrate.
Secondly I do not know if the above process is generic or some 开发者_运维知识库language or tool dependent. Can we make such application in WPF or Winforms?
Check out MEF.
The Managed Extensibility Framework (MEF) is a new library in .NET that enables greater reuse of applications and components. Using MEF, .NET applications can make the shift from being statically compiled to dynamically composed. If you are building extensible applications, extensible frameworks and application extensions, then MEF is for you.
It really depends on your applications design/layout/interface and the language used.
It's possible in C, C++, C# and many other languages but the real implementation depends on "how" you'd like it to work:
Many games (especially MMORPGs) allow the user to modify and extend their UI using some combination of XML and scripting files (e.g. Lua). This is the easier and more secure approach especially geared towards more inexperienced users (it's most likely easier to edit/update/use, your users won't have to understand a complete language and YOU decide what you expose).
Other programs use library files for plugins. The overall concept is similar to above, but it's harder to use (to create addons/extensions you have to know a supported programming language) and you might expose more than you'd like to (e.g. addons can modify parts of your program you didn't want them to touch).
The generic process is always similar:
- Lookup the available addon files (xml files, lua files, xul files, zip files, dll files, ... your decision)
- Load and evaluate the files (e.g. load the script file, parse the xml file or load the dll)
- Run your code or the code provided by the addon files or call code inside those files, etc.
As you've tagged this under C# I guess you'd prefer the dll/assembly approach. There are other questions with working solutions, e.g. this one.
If you're focussed on WPF and .NET specifically, check out Mono.Addins. There is a list of projects that use Mono.Addins on the documentation site - I'm sure that you can find many examples of how to write an add-in ready application from there.
As far as the correct design goes, this is a little tricky to get right. If you follow the packaging principles mentioned in Robert C. Martin's book, Agile Software Development, Principles, Patterns and Practices, the design of your application will naturally allow for addins. Two principles that are of particular importance is the Dependency Inversion Principle and the Stable Abstraction Principle.
You might want to look at LuaInterface. You have total control over what and how runs in the files!
精彩评论