Workaround for Delegate.CreateDelegate method?

  • Thread starter Thread starter Darren Coleman
  • Start date Start date
D

Darren Coleman

I was wondering if anyone had a work around for Delegate.CreateDelegate?
That method isn't in CF2.0. I'm just porting some .net code over CF2.0

sample code i'm working on

MyDelegate instanceOfMyDelegate = (MyDelegate )
Delegate.CreateDelegate(typeof(MyDelegate ), this._parent, meth.Name);
 
Ok figured it out; found what i was looking for on code project. He's my
refactord version of the code. I HAVE NOT TESTED THIS CODE, use at your own
risk. You'll have to change the "Invoke" method to match want you want to
do. More of a quick and dirty solution as i only need to do it with one
method/class

link that helped out
http://www.codeproject.com/netcf/UsingMyXamlCF.asp
public class CreateMyDelegate
{
object _eventTarget;
MethodInfo _method;
private CreateMyDelegate(MethodInfo method, object eventTarget)
{
_eventTarget = eventTarget;
_method = method;
}

private bool Invoke(Pram1 pram1, string detail, params object[] data)
{
object[] items = new object[] { parm1, detail, data };
return (bool)_method.Invoke(_eventTarget, items);
}

public static MyDelegate CreateDelegate(MethodInfo method, object
eventTarget)
{
CreateMyDelegate del = new CreateMyDelegate(method,eventTarget);
MyDelegate result = new MyDelegate(del.Invoke);
return result;
}
}
 
Back
Top