mardi 31 mars 2015

ParameterExpression to Object Casting with Reflection

I want to cast any object from ParameterExpression class.


This is sample code :



public void Execute(Expression<Action<TService>> operation)
{
try
{

var param = operation.Parameters[0]; //myparameter to cast
var obj = param as AnyCastObject; // I want to cast
DoSomething(obj); // and do something this object without losing any assigned propery.

operation.Compile().Invoke(OpenNewChannel);
}
finally
{
CloseChannel();
}
}





Aucun commentaire:

Enregistrer un commentaire