473,372 Members | 1,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Reflection / Delegate Question

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
Jan 7 '06 #1
4 1484
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.net
Jan 7 '06 #2
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*************@individual.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.net

Jan 7 '06 #3
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*************@individual.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.net


Here is a extremely simplified version of what I do:

using System;
using System.Windows.Forms;

namespace ConsoleApplication13
{
public interface PlugIn
{
Menu Menu(object context);
}

class PlugInImp : PlugIn
{
Menu PlugIn.Menu(object context)
{
ContextMenu mnu = new ContextMenu();
mnu.MenuItems.Add("My Menu Item", new
EventHandler(OnMyMnuClick));

return mnu;
}
private void OnMyMnuClick(object 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.RegisterPlugIn(new PlugInImp());
}
}
}

HTH,
Andy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40@*NO*SPAM*gmx.net
Jan 7 '06 #4
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*************@individual.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*************@individual.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.net


Here is a extremely simplified version of what I do:

using System;
using System.Windows.Forms;

namespace ConsoleApplication13
{
public interface PlugIn
{
Menu Menu(object context);
}

class PlugInImp : PlugIn
{
Menu PlugIn.Menu(object context)
{
ContextMenu mnu = new ContextMenu();
mnu.MenuItems.Add("My Menu Item", new
EventHandler(OnMyMnuClick));

return mnu;
}
private void OnMyMnuClick(object 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.RegisterPlugIn(new PlugInImp());
}
}
}

HTH,
Andy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40@*NO*SPAM*gmx.net

Jan 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
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...
4
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...
3
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...
3
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...
1
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...
2
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
2
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...
10
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......
5
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.