Hi
What is the nitty gritty around monkey patching CLR classes. When I’m
monkey
patching I should be able to get to the protected members of a class
right?
And the private members too (I see it kind of like partial classes)?
public class AggregatorRepository :
RepositoryBase
{
public
AggregatorRepository(UnitOfWorkScopeBase
unitOfWorkScope) : base(unitOfWorkScope)
{
}
//Some C# methods here that use Linq and Expressions for querying
}
Repository base defines a protected property UnitOfWorkScope
I monkey patched it like so
module MediaAggregator
module Models
module Lightspeed
class AggregatorRepository
def users
uow.method(:find).of(User).call
end
def uow
self.unit_of_work_scope.current
end
end
end
end
end
Calling the users method result in an error complaining about a
protected
unit_of_work_scope method. And ironically the error talks about my
situation
as being the solution:
*
*
C**LR protected method `unit_of_work_scope’ called for
MediaAggregator.Models.Lightspeed.AggregatorRepository:MediaAggregator::Models::Lightspeed::AggregatorRepository;
CLR protected methods can only be called with a receiver whose class is
a
subclass of the class declaring the method
Do I put this on codeplex or am I reading the error wrong? As far as I
can
tell I am subclassing a class.
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)