Hi,
I 'hacked' something up for you.
Please be aware that I didn't incorporate any checks, such as checking for array bounds etc.
This works for the string you provided.
class SellEntry
{
public SellEntry(string name, string value)
{
this.Name = name;
this.Value = value;
}
public string Name { get; set; }
public string Value { get; set; }
}
class MultiSellRecord
{
public MultiSellRecord(string value1, string value2, string isDutyFree)
{
this.Value1 = value1;
this.Value2 = value2;
this.IsDutyFree = isDutyFree;
this.SellList = new List<list><SellEntry>>();
}
public string Value1 { get; set; }
public string Value2 { get; set; }
public string IsDutyFree { get; set; }
public List<list><SellEntry>> SellList { get; set; }
}
MultiSellRecord Read(string str)
{
string[] split = str.Split(new[] { Environment.NewLine, "\t" }, StringSplitOptions.RemoveEmptyEntries);
int dutyIndex = split[4].IndexOf("=");
string isDutyFree = split[4].Substring(dutyIndex + 1).Trim();
string value1 = split[2].Replace("[", string.Empty).Replace("]", string.Empty);
MultiSellRecord multiEntry = new MultiSellRecord(value1, split[3], isDutyFree);
for (int i = 6; i < split.Length; i++)
{
if (split[i] == "}")
{
break;
}
var list = split[i].Split(new[] { "{", "}", ";", "[", "]" }, StringSplitOptions.RemoveEmptyEntries);
var sellList = new List<SellEntry>();
for (int j = 0; j < list.Length; j += 2)
{
sellList.Add(new SellEntry(list[j], list[j + 1]));
}
multiEntry.SellList.Add(sellList);
}
return multiEntry;
}
Bye,
Thomas.