C# monkey patching - is it possible?
Posted
by Adal
on Stack Overflow
See other posts from Stack Overflow
or by Adal
Published on 2010-05-17T23:34:13Z
Indexed on
2010/05/17
23:40 UTC
Read the original article
Hit count: 329
Is it possible to write a C# assembly which when loaded will inject a method into a class from another assembly? If yes, will the injected method be available from languages using DLR, like IronPython?
namespace IronPython.Runtime
{
public class Bytes : IList<byte>, ICodeFormattable, IExpressionSerializable
{
internal byte[] _bytes;
//I WANT TO INJECT THIS METHOD
public byte[] getbytes()
{
return _bytes;
}
}
}
I need that method, and I would like to avoid recompiling IronPython if possible.
© Stack Overflow or respective owner