while writing the question subject I came across some other allmost related post ...leading to MSDN http://msdn.microsoft.com/en-us/library/system.reflection.parameterinfo.aspx
but i couldn't manage to extract the bit of code i needed
i just learnd how to get method name with a helper method based on st and sf as following :
public void setLogView(View ViewMode)
{
AAdToAppLog();
Lview_AH_AutomationLog.Sorting = SortOrder.Ascending;
ColumnHeader ColHeadRowNo = new ColumnHeader();
ColumnHeader ColHeadFunction = new ColumnHeader();
ColumnHeader ColHeadContent = new ColumnHeader();
ColumnHeader ColHeadTime = new ColumnHeader();
Lview_AH_AutomationLog.View = ViewMode;
Lview_AH_AutomationLog.Columns.Add(ColHeadRowNo);
Lview_AH_AutomationLog.Columns.Add(ColHeadFunction);
Lview_AH_AutomationLog.Columns.Add(ColHeadContent);
Lview_AH_AutomationLog.Columns.Add(ColHeadTime);
ColHeadRowNo.Text = "#";
ColHeadFunction.Text = "Function Name";
ColHeadContent.Text = "Content";
ColHeadTime.Text = "Time";
ColHeadRowNo.Width = 45;
ColHeadFunction.Width = 150;
ColHeadContent.Width = 150;
ColHeadTime.Width = 100;
}
public void AAdToAppLog(string FunctionOutPut = "N/A")
{
string t = DateTime.Now.ToString("mm:ss.ff");
string h = DateTime.Now.ToString("HH");
ListViewItem FirstCell= new ListViewItem();
FirstCell.Text =h+":" +pre0Tosingle_9(LogCounter.ToString());//Another helper puts 0 infront <=9 digits
Lview_AH_AutomationLog.Items.Insert(0, FirstCell);
StackTrace st = new StackTrace();
StackFrame sf = st.GetFrame(1);
string FunctionName = sf.GetMethod().ToString().Replace("Void", "").Replace("System.Windows.Forms.", "");
FirstCell.SubItems.Add(FunctionName);
FirstCell.SubItems.Add(FunctionOutPut);
FirstCell.SubItems.Add(t);
LogCounter++;
}
so in every method i want i just put the
AddToAppLog()
that method contains my call to AddToAppLog() and then reports(Via ListView) the name of method and i just added the time of the call.
there's two things i would like to address in this post , about my implementation of that helper metod : the "FunctionName" i recive from sf.GetMethod is nice that it throws the type of the Parameter of a given Method i liked the idea , only that it is containing parameter.type's Father + Grandfather + Great-Grandfather, but i would like only the bottom Type :
System.Windows.Forms.View
this is one of the shortest (: and i tried to get to View by it self via playing with .Replace() so is there anothere way to strip it down or actually another method in same family that extract it the way i mentiond above or i could use a list containing every possible most-used types and do a foreach with stringReplace?
and more importently , how do i get the Method(parameterName) as well ?
thanks alot in advance !!
can someone Show An easy to comprehend , Simple syntax Example of getting parameters name ?