I need to know how to get the owning instance of a TableAdapter
if I just have the Table Adapter
.
So, for example, there is this class:
public class example
{
public User _user;
public TableAdapter _adapter;
someMethods();
.
.
.
}
I work with the aspect-oriented framework PostSharp. For logging purposes I have a logging class with a method that gets executed when the get_Adapter method is called. So, in my logging class I get the TableAdapter
as an argument. What I need in the end is the User object.
Unfortunately, I cannot change anything in the design of the class I need to get, so all I have is this TableAdapter
. My logging class looks like this (simplified):
public class logger
{
public override void OnExit(MethodExecutionArgs args)
{
TableAdapter = (TableAdapter)args.Instance;
//here I need the example object in order to get the current user object
}
}
Is there any way to do this? Reflection, maybe? Anything?
Thanks for help in advance.
Oh, by the way, I work with C# and WinForms.