It's a bit tricky question and I don't know if it's possible.
Let's say that I have a class Foo1 that's in a DLL and I can't modify it. The class looks like this:
public class Foo1<T1> : IFoo<T1>
{
public Foo1(Func<IFoo, T1, T1> postRead);
}
I want to inherit Foo1 and be able to inject a T2 object in the original postRead and access it in the base postRead.
Something like this:
public class Foo2<T1, T2> : Foo<T1>
{
public Foo2(Func<IFoo, T1, T2, T1> newPostRead)
:base(Func<IFoo, T1, T1> secondPostRead)
{
}
}
Is it possible?
EDIT: I'm using insight DB. It's an ORM. There's feature that does post processing. The code looks like this:
public class PostProcessRecordReader<T> : RecordReader<T>
{
public PostProcessRecordReader(Func<IDataReader, T, T> postRead);
}
//How to use the processor
public DummyFunction(ObjectIWantToUse objectIwantToUse)
{
PostProcessRecordReader<Foo> _postProcessorForCubeWithAllEntitiesForBuilding = new PostProcessRecordReader<Foo> (reader, obj) =>
{
//Need to have access objectIwantToUse !!!
//maybe I want to modify obj or add some stuff to it
}
);
//Do some stuff by using _postProcessorForCubeWithAllEntitiesForBuilding
}
We can do some processing on the object once returned from the DB, by accessing directly the reader.
Foo1<T1>takes a function that has twoT1parameters and returns anIFoo<T1>. I presums thatFoo1calls that function at some point.You are wanting to pass it a function that takes two
T1parameters and aT2parameter. The problem is -Foo1knows nothing aboutT2- so how is it supposed to know what to pass in?Now
Foo2knows aboutT2but has to pass that information on to T1 somehow. It could map the original function to one with less parameters, but it would have to have some sort of resolver that knows whatT2should be:It will at least compile, but it's not clear from your description if this is a viable solution.