Structural analysis and create with the help of LinQ and a good interface

  • Thread starter Thread starter Markus Freitag
  • Start date Start date
M

Markus Freitag

Guest
Hello,
---> to customer, 9 arguments:
[1]: ID|20200011
[2]: REF|9919000000011001
[3]: SNO|9919000000011001|001|0
[4]: SNO|9919000000011002|002|0
[5]: SNO|9919000000011003|003|0
[6]: SNO|9919000000011004|004|0
[7]: SNO_SUM|4
[8]: GROUP|A
[9]: CATEGORY|A|PriceSegment-C
1490395.jpg

public int custExchangeFunct(string[] inArgs, out string[] outArgs, out string errorInterface);
I need to send requests to an interface that can look like this.
The structure is always key value. The key can have several values separated by the character |
Example
ID = 20200011
SNO = 9919000000011003 Subunit 003 next is 0

I'm looking for ways to create this the easiest way. With interface, class.
ListMaster.Add(key, value)

ListMaster.Add(key, ListDetail.join(|) )
If I get such a structure back from the customer, how can I quickly analyze it into objects?

string res = string.Join("|", Liste);
///////////////////////////////

public class MasterDetail
{
public string Key { set; get; }
public List<string> Value;

public MasterDetail()
{
Value = new List<string>();
}
}
string inp = @"SNO|9919000000011003|003|0|4214|314424";
MasterDetail testMasterDetail = new MasterDetail();
int index = inp.IndexOf('|');
testMasterDetail.Key = inp.Substring(0, index);
string detail = inp.Substring(index + 1, inp.Length - (index+1));
testMasterDetail.Value.AddRange(from item in detail.Split('|') select item);

// Master
// List with key, value
// value == List with values
So I can work more easily.
Thanks in advance for tipps.
Best regards Markus

Continue reading...
 
Back
Top