I have an interface called IAuditable as follows:
public interface IAuditable
{
string AuditSummary
{
get;
}
string AuditDetails
{
get;
}
}
And two generic method in AuditTrail class as follows:
public T GetActualOldValue<T>() where T : IAuditable
{
return FromXElement<T>(OldValue);
}
public T GetActualNewValue<T>() where T : IAuditable
{
return FromXElement<T>(NewValue);
}
as well as i have one property to returning Audit Summary by getting a class at run time as follows:
public string AuditSummary
{
get
{
if (HasNewValue || HasOldValue)
{
string libraryVal = GetLibraryValue();
Assembly assembly = Assembly.Load(libraryVal);
foreach (Type type in assembly.GetTypes())
{
if (type.IsClass == true)
{
if (type.FullName.EndsWith("." + ClassName))
{
/*Here i want to call GetActualNewValue<foundClass>().AuditSummary
* or GetActualOldValue<foundClass>().AuditSummary;
*/
}
}
}
}
return "";
}
}
As you know we can find class at run time in specific library, Please note i don't want to call a generic method at run time,just wanna call generic method with founded, in other words how can i pass a specific class to GetActualNewValue<...>() as T,
AuditTrail auditTrail = AuditTrail.GetAuditTrail(76);
string summmary = auditTrail.GetActualOldValue<DTClient>().AuditSummary;
string details = auditTrail.GetActualOldValue<DTClient>().AuditDetails;
This code work perfectly but the main problem is DTClient must find at run time and define as T for GetActualValue.
Thanks all.