I have to call the following method:
public bool Push(button RemoteButtons)
RemoteButtons is defined this way:
enum RemoteButtons { Play, Pause, Stop }
The Push method belongs to the RemoteControl class. Both the RemoteControl class and the RemoteButton enumeration are located inside an assembly that I need to load at runtime. I'm able to load the assembly and create an instance of RemoteControl this way:
Assembly asm = Assembly.LoadFrom(dllPath);
Type remoteControlType = asm.GetType("RemoteControl");
object remote = Activator.CreateInstance(remoteControlType);
Now, how do I call the Push method knowing that it's sole argument is an enum that I also need to load at runtime?
If I was on C# 4, I would use a dynamic
object but I'm on C# 3/.NET 3.5 so it's not available.
enum RemoteButtons { Play, Pause, Stop }
...if this is correct, the OP needs to make this clear. :) – CaylaIRemoteControl
- which exposesbool Push(...)
and referenced by the class instantiating via reflection and implemented byRemoteControl
. Then you don't have to call the method via reflection. – Cayla