Hi,
I've developed a plug-in application that basically is constructed of 2
pieces 1). the "main framework" 2). channels. Using Reflection in the Main
Framework, i dynamically load Channels. This works fine and great. My
problem is w/ menus. Each Channel returns a Popup Menu (based on an
interface requirement) that gets placed in the Main Framework's main
menubar. Again, works fine. However, what i'm unsure of is the
eventhandler for those specific menu choices. Since the Main Framework only
Hosts the Channel and adds the menu choices to the Main menu bar, when a
user clicks on one of those specific menu items, the Framework does NOT know
what to do with it only the individual Channel will.
Question: If I'm using the wrong approach on this question, please correct
me - how do I dynamically (via Reflection) pass that event firing back to
the Channel? I can't have any hardcoded values in the Framework because I
don't know what each Channel will require. Any sort of example code would
be great if possible or a URL to something.
Thanks in advance,
Doug 4 1500
Doug Handler wrote: Hi,
I've developed a plug-in application that basically is constructed of 2 pieces 1). the "main framework" 2). channels. Using Reflection in the Main Framework, i dynamically load Channels. This works fine and great. My problem is w/ menus. Each Channel returns a Popup Menu (based on an interface requirement) that gets placed in the Main Framework's main menubar. Again, works fine. However, what i'm unsure of is the eventhandler for those specific menu choices. Since the Main Framework only Hosts the Channel and adds the menu choices to the Main menu bar, when a user clicks on one of those specific menu items, the Framework does NOT know what to do with it only the individual Channel will.
Question: If I'm using the wrong approach on this question, please correct me - how do I dynamically (via Reflection) pass that event firing back to the Channel? I can't have any hardcoded values in the Framework because I don't know what each Channel will require. Any sort of example code would be great if possible or a URL to something.
Thanks in advance, Doug
I have a similar application. What I do is when I create the context
menus inside my plugins I hook up the events right away to handlers
inside of my plugin. So there is actually no overhead in my hosting
framework.
HTH,
Andy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40 @*NO*SPAM*gmx.n et
Andreas,
Thanks for the info...I hate to impose, but can you provide me a quick
example so i know exactly what you mean. Right now i'm trying to use
CreateDelegate (via Reflection) and I'm not being very successful <sigh>
d
"Andreas Mueller" <me@privacy.net > wrote in message
news:42******** *****@individua l.net... Doug Handler wrote: Hi,
I've developed a plug-in application that basically is constructed of 2 pieces 1). the "main framework" 2). channels. Using Reflection in the Main Framework, i dynamically load Channels. This works fine and great. My problem is w/ menus. Each Channel returns a Popup Menu (based on an interface requirement) that gets placed in the Main Framework's main menubar. Again, works fine. However, what i'm unsure of is the eventhandler for those specific menu choices. Since the Main Framework only Hosts the Channel and adds the menu choices to the Main menu bar, when a user clicks on one of those specific menu items, the Framework does NOT know what to do with it only the individual Channel will.
Question: If I'm using the wrong approach on this question, please correct me - how do I dynamically (via Reflection) pass that event firing back to the Channel? I can't have any hardcoded values in the Framework because I don't know what each Channel will require. Any sort of example code would be great if possible or a URL to something.
Thanks in advance, Doug I have a similar application. What I do is when I create the context menus inside my plugins I hook up the events right away to handlers inside of my plugin. So there is actually no overhead in my hosting framework.
HTH, Andy -- To email me directly, please remove the *NO*SPAM* parts below: *NO*SPAM*xmen40 @*NO*SPAM*gmx.n et
Doug Handler wrote: Andreas,
Thanks for the info...I hate to impose, but can you provide me a quick example so i know exactly what you mean. Right now i'm trying to use CreateDelegate (via Reflection) and I'm not being very successful <sigh>
d "Andreas Mueller" <me@privacy.net > wrote in message news:42******** *****@individua l.net...
Doug Handler wrote:
Hi,
I've developed a plug-in application that basically is constructed of 2 pieces 1). the "main framework" 2). channels. Using Reflection in the Main Framework, i dynamically load Channels. This works fine and great. My problem is w/ menus. Each Channel returns a Popup Menu (based on an interface requirement) that gets placed in the Main Framework's main menubar. Again, works fine. However, what i'm unsure of is the eventhandl er for those specific menu choices. Since the Main Framework only Hosts the Channel and adds the menu choices to the Main menu bar, when a user clicks on one of those specific menu items, the Framework does NOT know what to do with it only the individual Channel will.
Question: If I'm using the wrong approach on this question, please correct me - how do I dynamically (via Reflection) pass that event firing back to the Channel? I can't have any hardcoded values in the Framework because I don't know what each Channel will require. Any sort of example code would be great if possible or a URL to something.
Thanks in advance, Doug
I have a similar application. What I do is when I create the context menus inside my plugins I hook up the events right away to handlers inside of my plugin. So there is actually no overhead in my hosting framework.
HTH, Andy -- To email me directly, please remove the *NO*SPAM* parts below: *NO*SPAM*xmen 40@*NO*SPAM*gmx .net
Here is a extremely simplified version of what I do:
using System;
using System.Windows. Forms;
namespace ConsoleApplicat ion13
{
public interface PlugIn
{
Menu Menu(object context);
}
class PlugInImp : PlugIn
{
Menu PlugIn.Menu(obj ect context)
{
ContextMenu mnu = new ContextMenu();
mnu.MenuItems.A dd("My Menu Item", new
EventHandler(On MyMnuClick));
return mnu;
}
private void OnMyMnuClick(ob ject sender, EventArgs e)
{
// do click stuff
}
}
public static class HostFramework
{
public static void RegisterPlugIn( PlugIn pl)
{
Menu mnu = pl.Menu(null);
HookUpMenu(mnu) ;
}
private static void HookUpMenu(Menu mnu)
{
// ...
}
}
class Program
{
static void Main(string[] args)
{
// in the real world, this happens inside of a
// plugin init code
HostFramework.R egisterPlugIn(n ew PlugInImp());
}
}
}
HTH,
Andy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40 @*NO*SPAM*gmx.n et
Ok, on the same page....cool, thank you. I PM'd you, prior, so disregard.
dh
"Andreas Mueller" <me@privacy.net > wrote in message
news:42******** *****@individua l.net... Doug Handler wrote:
Andreas,
Thanks for the info...I hate to impose, but can you provide me a quick example so i know exactly what you mean. Right now i'm trying to use CreateDelegate (via Reflection) and I'm not being very successful <sigh>
d "Andreas Mueller" <me@privacy.net > wrote in message news:42******** *****@individua l.net...
Doug Handler wrote:
Hi,
I've developed a plug-in application that basically is constructed of 2 pieces 1). the "main framework" 2). channels. Using Reflection in the Main Framework, i dynamically load Channels. This works fine and great. My problem is w/ menus. Each Channel returns a Popup Menu (based on an interface requirement) that gets placed in the Main Framework's main menubar. Again, works fine. However, what i'm unsure of is the eventhandle r for those specific menu choices. Since the Main Framework only Hosts the Channel and adds the menu choices to the Main menu bar, when a user clicks on one of those specific menu items, the Framework does NOT know what to do with it only the individual Channel will.
Question: If I'm using the wrong approach on this question, please correct me - how do I dynamically (via Reflection) pass that event firing back to the Channel? I can't have any hardcoded values in the Framework because I don't know what each Channel will require. Any sort of example code would be great if possible or a URL to something.
Thanks in advance, Doug
I have a similar application. What I do is when I create the context menus inside my plugins I hook up the events right away to handlers inside of my plugin. So there is actually no overhead in my hosting framework.
HTH, Andy -- To email me directly, please remove the *NO*SPAM* parts below: *NO*SPAM*xme n40@*NO*SPAM*gm x.net Here is a extremely simplified version of what I do:
using System; using System.Windows. Forms;
namespace ConsoleApplicat ion13 { public interface PlugIn { Menu Menu(object context); }
class PlugInImp : PlugIn { Menu PlugIn.Menu(obj ect context) { ContextMenu mnu = new ContextMenu(); mnu.MenuItems.A dd("My Menu Item", new EventHandler(On MyMnuClick));
return mnu; } private void OnMyMnuClick(ob ject sender, EventArgs e) { // do click stuff } }
public static class HostFramework { public static void RegisterPlugIn( PlugIn pl) { Menu mnu = pl.Menu(null); HookUpMenu(mnu) ; } private static void HookUpMenu(Menu mnu) { // ... } } class Program { static void Main(string[] args) { // in the real world, this happens inside of a // plugin init code HostFramework.R egisterPlugIn(n ew PlugInImp()); } } }
HTH, Andy -- To email me directly, please remove the *NO*SPAM* parts below: *NO*SPAM*xmen40 @*NO*SPAM*gmx.n et This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: BK |
last post by:
Hi,
I have a class which has a lot of events (>100). For some reasons, I have to
go through all invocation lists to do something. What I'm wondering is that,
is there any way to use reflection to get their InvocationList without going
through each event?
// tedious
foreach (Delegate handler in Event1.GetInvocationList()) {...}
foreach (Delegate handler in Event2.GetInvocationList()) {...}
|
by: Tim Werth |
last post by:
I am trying to use reflection to add an event handler for the RowUpdated
event of the OracleDataAdapter object (ODP.NET), but the same thing can be
said for SqlDataAdapter if you only use reflection. The code I supplied is
based on the SqlDataAdapter with reflection.
The error occurs when trying to create the delegate that will be passed in
to EventInfo.AddEventHandler. I get the following error:
An unhandled exception of type...
|
by: timothy |
last post by:
Hi,
I have created a Delegate with EventArgs and I am trying to use reflection
to pick the correct EventArg. I have a combo box loaded with strings where
each represents an event arg for this delegate. I was hoping to make it
dynamic when the user selects the criteria in the combo box that I could
point to the correct event arg which I pass to the delegate. Should I use
reflection and how? Or is there a better way?
Thanks
|
by: Ben Fidge |
last post by:
Hi
Is it possible, using Reflection, to determine at runtime the method(s) that
are provided as handler for a given controls events?
Also, once discovered, is it possible to manually invoke these methods?
For example, suppose I have a ImageButton on a webform that has an on click
handler associated. I would like to be able to discover the name of the
event handling method(s) that handle this event, and manually invoke them.
|
by: Pieter Breed |
last post by:
Hi All,
I am trying to use the attribute/reflection system to as much
potential as I can think of, but I've run into a snag. I would
appreciate it if someone would point me in the right direction.
First my question: How am I supposed to make instances of delegates
when I have the method (that I want to make the delegate of) retrieved
through reflection?
| |
by: Luis Arvayo |
last post by:
Hi,
In c#, I need to dynamically create types at runtime that will consist of
the following:
- inherits from a given interface
- will have a constructor with an int argument
|
by: mswlogo |
last post by:
I looked high and low for code to do this and finally found some VB
code that did it right.
This is a C# flavor of it.
public event EventHandler<EventArgsMyEventToBeFired;
public void FireEvent(Guid instanceId, string handler)
{
EventArgs e = new EventArgs(instanceId);
|
by: Ron |
last post by:
I have a situation where I have an object name as a string, and a method as
a string. I need to construct a click handler with those two bits of
information. This is what I came up with so far... and the error message I
am receiving...
Assembly assem = Assembly.GetExecutingAssembly();
string currentNamespace =
Assembly.GetExecutingAssembly().GetTypes().Namespace;
Type type = assem.GetType(currentNamespace + "." + m_FormName, true,...
|
by: Klaudiusz Bryja |
last post by:
Hi,
This is for NetCF 2.0.
I need to create event handling code which using reflection. I have
some parameters in XML which describe how event should be handled. I
have code to create delegate:
public class DelegateEx
{
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |