DispatchEntry DispatchTable - Converting C++ to C#

  • Thread starter Thread starter jwgoerlich
  • Start date Start date
J

jwgoerlich

Hello group,

How would one write the following C++ code in C#? What .Net object
could I use for a DispatchEntry?

DispatchEntry DispatchTable[] = {
{ TEXT("classfilter"), cmdClassFilter, MSG_CLASSFILTER_SHORT,
MSG_CLASSFILTER_LONG },
{ TEXT("classes"), cmdClasses, MSG_CLASSES_SHORT,
MSG_CLASSES_LONG },
{ NULL,NULL }
};

Thanks,

J Wolfgang Goerlich
 
I can't find anything in MSDN as to what that is.

However, if I had to guess, it is some sort of command framework, which
..NET doesn't have an equivalent for (at least in Windows Forms, with WPF,
there is a command infrastructure). You would have to write something
yourself in this case.
 
Nicholas said:
However, if I had to guess, it is some sort of command framework, which
.NET doesn't have an equivalent for (at least in Windows Forms, with WPF,
there is a command infrastructure). You would have to write something
yourself in this case.


Makes sense. The second parameter (cmd*) is pointing to a method. The
procedures that call this use it to pass control to other procedures.
I can create something similiar using a struct and an array. What
object type should I use to represent the method, though?

J Wolfgang Goerlich

private struct DispatchEntry
{
public string cmdString;
public ????? memberProcedure;
public uint shortHelp;
public uint longHelp;

public DispatchEntry(string command, ????? procedure, uint help1,
uint help2)
{
cmdString = command;
memberProcedure = Function;
shortHelp = help1;
longHelp = help2;
}

}

DispatchEntry[] DispatchTable = {
new DispatchEntry("classfilter", cmdClassFilter,
MSG_CLASSFILTER_SHORT, MSG_CLASSFILTER_LONG),
new DispatchEntry("classes", cmdClasses, MSG_CLASSES_SHORT,
MSG_CLASSES_LONG),
new DispatchEntry("disable", cmdDisable, MSG_DISABLE_SHORT,
MSG_DISABLE_LONG)
}
 
Nicholas said:
However, if I had to guess, it is some sort of command framework,
which
.NET doesn't have an equivalent for (at least in Windows Forms, with WPF,
there is a command infrastructure). You would have to write something
yourself in this case.


Makes sense. The second parameter (cmd*) is pointing to a method. The
procedures that call this use it to pass control to other procedures.
I can create something similiar using a struct and an array. What
object type should I use to represent the method, though?

J Wolfgang Goerlich

private struct DispatchEntry
{
public string cmdString;
public ????? memberProcedure;
public uint shortHelp;
public uint longHelp;

public DispatchEntry(string command, ????? procedure, uint help1,
uint help2)
{
cmdString = command;
memberProcedure = Function;
shortHelp = help1;
longHelp = help2;
}

}

DispatchEntry[] DispatchTable = {
new DispatchEntry("classfilter", cmdClassFilter,
MSG_CLASSFILTER_SHORT, MSG_CLASSFILTER_LONG),
new DispatchEntry("classes", cmdClasses, MSG_CLASSES_SHORT,
MSG_CLASSES_LONG),
new DispatchEntry("disable", cmdDisable, MSG_DISABLE_SHORT,
MSG_DISABLE_LONG)
}


?????? = delegate

Willy.
 
?????? = delegate

Is there more to it? The following code results in an "Identifier
expected" compiler error.

private struct DispatchEntry
{
public string cmdString;
public delegate memberProcedure;
public uint shortHelp;
public uint longHelp;
}
 
Is there more to it? The following code results in an "Identifier
expected" compiler error.

private struct DispatchEntry
{
public string cmdString;
public delegate memberProcedure;
public uint shortHelp;
public uint longHelp;
}


It depends on the method signature, here is a sample:

delegate void SomeMethod();

I'm not relly clear on what you are trying to achieve with this structure,
is this to be used in an interop scenario or what?

Willy.
 
Thank you, I will play around with delegate some more.
I'm not relly clear on what you are trying to achieve with this structure,
is this to be used in an interop scenario or what?

I am converting existing C++ code. It looks up the functions in this
table and uses that to pass control from one member to another.

J Wolfgang Goerlich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top