0
public void TestGeneric<TSource,TDestination>(IOverride<TSource,TDestination> override)
{
   do something
}

public void calling_method<TLValue, TRValue>(TLValue leftValue, TRValue rightValue)
{
     Type Source = leftValue.GetProperies().firstOrDefault();
     Type Destination = rightValue.GetProperies().firstOrDefault();
     var override = some method;
     TestGeneric<Source,Destination>(override);
} 

I am having generic method which is having TSource and TDestination. On the basis of this two it do some operations.

In calling method i can get the type which i have to pass. I want do like

TestGeneric<Source,Destination>();

How to do that

leppie
  • 115,091
  • 17
  • 196
  • 297
Hemant Malpote
  • 891
  • 13
  • 28
  • You're looking for reflection. Suggested duplicate question will help. It is there right above your question. – Sriram Sakthivel Jan 06 '15 at 11:50
  • I know its already asked question. Actually the problem is with passing parameter – Hemant Malpote Jan 06 '15 at 12:16
  • What parameter? The example you posted doesn't have any parameter. Please explain what is your problem, simply saying problem isn't helpful. – Sriram Sakthivel Jan 06 '15 at 12:18
  • Sorry i just update the question please find it – Hemant Malpote Jan 06 '15 at 12:18
  • Second parameter of `Invoke` takes the parameters to the method You can do something like this `generic.Invoke(this, new object[]{ override });` – Sriram Sakthivel Jan 06 '15 at 12:20
  • @Sriram the problem is with TestGeneric method. This method contain expression like override.Add(x=>x.someProperty, y=>y.SomePropert). If i change it to Array of object. It will not take expression – Hemant Malpote Jan 06 '15 at 12:25
  • We have no idea what is `IOverride` or what you're trying to achieve. Please post a [MVCE](http://stackoverflow.com/help/mcve) and make the question clear. If the question is clear enough and a different one I'll reopen it. – Sriram Sakthivel Jan 06 '15 at 12:28
  • IOverride is interface whose add method do mapping between source and destination. So as usual it need expression. – Hemant Malpote Jan 06 '15 at 12:31
  • IOverride Add(Expression> destination, Expression> overrideFunction); this is signature of Add – Hemant Malpote Jan 06 '15 at 12:33

0 Answers0