I'm using reflection to grab a field that happens to be a delegate. I need to replace this delegate with my own, but the type of the delegate is private (so I can't create it from my method and assign it)
I have a delegate type with an exactly matching signature, so is there some way I can dynamically cast my delegate to this other type? I have a Type object representing the unknown type.
I realize what I've said above may not very clear, so here's some code:
var delegate_type = Assembly.GetAssembly(typeof(A.F))
// public delegate in A.ZD (internal class)
.GetType("A.ZD+WD");
The type signature of the A.ZD+WS
(obfuscated name) delegate is void(System.Drawing.Graphics)
.
Is there a way I can cast an Action<Graphics>
to this delegate type?