(At first I had to check, but I'm tired - this is basically a duplicate .)
factory, Func<DataRow, T> . ( . , , Injection Dependency, .)
:
interface ISomething
{
}
class Something : ISomething
{
internal Something(DataRow row)
{
}
}
class FooClass<T> where T : ISomething , new()
{
private readonly Func<DataRow, T> factory;
internal FooClass(Func<DataRow, T> factory)
{
this.factory = factory;
}
void BarMethod(DataRow row)
{
T t = factory(row);
}
}
...
FooClass<Something> x = new FooClass<Something>(row => new Something(row));