I have this structure of classes:
public class L3Message
{
public int Number { get; set; }
public string MessageName { get; set; }
public string Device { get; set; }
public string Time { get; set; }
public string ScramblingCode { get; set; }
public List<Parameter> Parameters { get; set; }
public L3Message()
{
Parameters = new List<Parameter>();
}
}
public class Parameter
{
public int numOfWhitespaces { get; set; }
public string ParameterName { get; set; }
public string ParameterValue { get; set; }
public Parameter Parent { get; set; }
public List<Parameter> SubParameters { get; set; }
public Parameter()
{
SubParameters = new List<Parameter>();
}
}
So, as return type from one of my Methods I have List of L3Messages (List<L3Message>), and I need to map that to TreeView in WinForms (populate TreeView from that List).
EDIT:
Please notice that tree of my objects can be deeper than one level (becouse class Parameter have prop List < Parmaeter > (List of Parameter object, same structure as root parameter object)), so that means recursion or something like.
EDIT2:
Here is pic of tree, but this tree is created from text file base on whitespaces, so here is all Parameters, in my tree I need only one from List of L3Message objects.
http://imageshack.us/photo/my-images/803/treeviewmessage.png/
EDIT3:
I’m sure that my TreeView need to be something like this:
L3Message.Number: L3Message.MessageName
+L3Message.Time
+L3Message.Device
+L3Message.ScramblingCode
+L3Message.Parameters[0]
++Parameter.ParamaeterName: Parameter.ParameterValue
++ (same as above)
L3Message.Number: L3Message.MessageName
+L3Message.Time
+L3Message.Device
+L3Message.ScramblingCode
+L3Message.Parameters[0]
++Parameter.ParamaeterName: Parameter.ParameterValue (in this occasion Value is null )
+++SubParameter.ParameterName: SubParameter.ParameterValue
Something like that
If possible, I would like to that in separate thread.
How can I achieve that?
I managed to solve this, but I think that is not optimize and there is no separate thread.
If anyone can modify my code to perform better and add separate thread?
SOLUTION: