Search for string in class structure populated from XML import, how?


I am importing an XML file into a class structure(?) in C# Visual Studio. The structure classes looks like this.

[Serializable, XmlRoot("YamahaAmplifier")]
public class YamahaAmplifier
    [XmlElement(ElementName = "Root")]
    public List<Root> Roots = new List<Root>();

public class Root
    public string RootName = "";
    public string UseRoot = "";
    public List<Device> Devices = new List<Device>();

public class Device
    public string DeviceName = "";
    public string UseFunction = "";
    public string GETCMD = "";
    public string PUTCMD = "";
    public List<Parameter> Parameters = new List<Parameter>();

public class Parameter
    public int Number = 0;
    public string Type = "";
    public string Name = "";
    public string MinVal = "";
    public string MaxVal = "";

From the parameters imported I create buttons and sliders to corresponding to function the XML decribe. When pressing I button or sliding a slider I can make the program transmitt the PUTCMD and added information from the Parameter list. The tranmission is done over TCP.

Now to the problem. One of the roots may have a device which has a PUTCMD that for example is "@SYS:MODELNAME". This piece of information is used both for sending the command and for comparison of incomming commands. So when I get a message over TCP which reads "@SYS:MODELNAME" I need to do a search in the class structure to find it so that I may manipulate its corresponding device and parameters. For instance with this example write the model name arriving with the message into a text box.

So that I get the indexes (i, j) of the exact device roots.Roots[i].Devices[j] is found.

Greatful for any assistance!

Show source
| class   | xml   | search   | struct   2016-12-25 22:12 0 Answers

Answers ( 0 )

◀ Go back