|
|
Presumably there is a business reason driving this.
First step is to define exactly what a 'rule' does. It can't do everything in the known universe because it isn't possible for a consumer to code to such a requirement. So it has to be restricted to some sort of interface (not necessarily meaning the keyword but possibly meaning that) which the consumer knows how to use and manage.
That is a design step not an implementation step.
After you know what that looks like then you might want to look at the Microsoft Addin.
http://msdn.microsoft.com/en-us/library/gg145020.aspx[^]
Although it might be better to write one yourself.
|
|
|
|
|
todd.01011101 wrote: I'm looking for examples of or ideas about a mechanism whereby code with a
defined interface can be picked up and integrated into execution of another
piece of code at run time.
Most KISS solution I can come up with would be an application that simply polls the directory and which processes every file - getting the processor based on the extension of the files. Aw, the most KISS-way of building a processor would be a console-application that generates output, simply passing the path as an argument.
Would be quite easy to maintain and extend, in any language
Bastard Programmer from Hell
|
|
|
|
|
Since you are planning on versioning your logic, you will run into a .NET limitation that you cannot unload code once it is loaded into an app domain[^]. This is regardless of the plug-in discovery mechanism that you choose.
One way around this limitation is to run your plug-ins in separate app domains, unloading the entire app domain once you need to load the next version of a particular plug-in.
Since you cannot make plain old calls across app domain boundaries, so you'll need to design your interface carefully to avoid spending excessive time serializing and deserializing parameters and return values.
Here is the method I use to access items loaded into separate app domains: CreateInstanceAndUnwrap[^].
|
|
|
|
|
I don't expect *too much* churn of the plug-ins, (1, maybe 2 in a day) and the app domain is cycled every night by default so I'm not too worried about the old plug-ins stacking up and causing memory/performance issues. (If I've misinterpreted the outcome of the limitation you described, please set me straight).
That being said, thanks so much for your answer. I'm so glad I posted this here, I've got some great information, and great leads to follow.
I've been reading with eyes wide open all afternoon.
Todd
|
|
|
|
|
todd.01011101 wrote: I don't expect *too much* churn of the plug-ins, (1, maybe 2 in a day)
Every day?
Or when it occurs every 6 months it might involve 1/2?
If the first then perhaps you should look into some entirely different options such as scripting.
|
|
|
|
|
Yes, I meant that the maximum would be 1/2 in a day, but maybe once every few months.
Certainly not 1 or 2 every day.
|
|
|
|
|
You could look at writing dynamic assemblies or methods Using Reflection Emit
"You get that on the big jobs."
|
|
|
|
|
Ok, but how would you know what code to create dynamically? You would still need a mechanism to define the logic so it could be created dynamically. Sorry, not a very good suggestion for the problem, there are far easier methods that are more performant.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I have used Castle Windsor[^] to accomplish something similar. There are several other .NET inversion of control containers that may also work (StructureMap, Spring.Net, Ninject, etc.) but I don't have any experience with them.
Regards,
Eric
|
|
|
|
|
Given your rate, 1/2 every 6 months, I doubt a generic system is going to provide an advantage.
|
|
|
|
|
What about a scripting engine for the business system/ part of the business system. If you require functionality to be dynamic. It could be scripted and changed on the fly.
|
|
|
|
|
This is what I have used with one of my programs.
1: Have a page on the Internet with the latest version number.
2: When your application loads, read the Internet file version and if it is grater than your application then....
3. You can give the user the option to upgrade now or upgrade now without prompting the user.
4: Download and run a temp upgrade.exe program. Then quit your main application.
5: The upgrade.exe will download the new version (Using the same file names and locations as the old version)
6: Run the (new) main application.
7: End the upgrade.exe program.
|
|
|
|
|
|
Hi everyone.
Long story short I am working on a replacment shell in VB.net, and while i hav most of it sorted i am struggeling with one section.
The system tray. does anyone know how to (or can point me at a site that can help), make a system tray in VB.net (any of the .net languages is fine)
Thanks
Daniel
Edit
I forgot to mention that I know that the class that handels this in explorer.exe is System_trywnd
Hope that helps
modified on Tuesday, June 7, 2011 9:30 AM
|
|
|
|
|
|
no. I am trying to write a replacment windows shell and I have got to the stage where I need to replicate the system tray. The point where notify icons are placed. Sorry my orrigional post obviously wasnt verry clear on that.
Tanks anyway
daniel
|
|
|
|
|
Yeah, so write an implementation of NotifyIcon for your shell as I think the previous poster intended Basically, the interface for NotifyIcon tells you exactly which functionality is needed and how it is implemented. Basically you can use the same interface and supply a new implementation for it specific to your shell.
Edit:
On the implementation, basically what you need is a toolbar which can display icons, has customized menu's for each icon, has tooltips, and perhaps one or two more features. Here too, the NotifyIcon class gives great amounts of information how to implement each feature.
|
|
|
|
|
I am trying to implement a simply task that appears to be amazingly hard to accomplish in .Net: Sorting a column in a datasource bound control (e.g. DataGridView), not based on the underlying values (i.e. simple string comparison on the values) but on some custom rule that I want to define.
I have a DataGridView that is bound to a Bindingsource which in turn is (via Dataview, .Net internal stuff...) bound to a Datatable. This is plain vanilla stuff, out of the box. If I was happy with the default sort behavior, i.e. sorting columns by the values in DataTable, everything would be easy, even automatic.
However, some of the contents in the Datatable is not in a user-friendly format, so it must be formatted for display in the datagridview (e.g. by overriding the CellFormatting event). If I now sort the control by that column, the rows will be sorted by the underlying values, and not by the displayed text, which is bad.
I cannot use the Sort() function nor the IComparer overwrite of the DataGridView since I am working in databound mode. How in the world then can I intercept the sorting mechanism and tell the DataGridView how to sort this column properly?
It strikes me as odd that the standard data source - binding source - control model in .Net appears to have no provision at all for custom sorting! What is even odder is that a primary reason for the whole concept of a BindingSource is just sorting and filtering!
There must be an easier way than writing 1000s of lines of code to create my own DataView or IBindingList derived class that will allow this kind of customization, as recommended in various articles. This seems such a common scenario that I can't believe there is a more elegant way...
|
|
|
|
|
AFAIK you must apply your (custom) sort on the underlying data structure, not the DGV itself. So set the DGV to programmatic sorting, handle the cell click event (checking for row<0 and getting the column index), and sort your DataTable or whatever is underneath the DGV.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
I'm not sure I understand the difference between these two events (Form.Deactivate and Form.Leave). Could someone enlighten me please?
|
|
|
|
|
Occurs when the form loses focus and is no longer the active form. (When the title-bar of the form changes from blue to gray)
Occurs when the input focus leaves the control. (When the cursor focusses another control/window)
Bastard Programmer from Hell
|
|
|
|
|
Alright thanks, but isn't that pretty much the same thing? I'm talking specifically about a form, not just any control. So "when the cursor focusses another form", isn't that precisely when the form's title-bar changes from blue to grey?
|
|
|
|
|
Yup. The active form is usually the one with input-focus (fails sometime when apps modify the z-order). Hence, if the input-focus moves to a different form, the new form will should be activated. Even if the validation would fail and the focus retained - the active form would be the one with focus.
Bastard Programmer from Hell
|
|
|
|
|
OK, thanks. So, am I correct that, as regards Forms, there is no difference between Form.Deactivate and Form.Leave?
|
|
|
|