public static XFormat CreateXFormat(XElement xe) { XFormat xf = new XFormat(); xf.gsName = xe.Name.LocalName; xf.gsFormat = xe.zAttribValue("format"); if (xf.gsFormat != null) { xf.gFormats = StringZones.SplitZone(xf.gsFormat, new char[,] { { '{', '}' } }); string sFormat = ""; int i = 0; xf.gFormatValues = new List<XValueFormat>(); foreach (StringZone format in xf.gFormats) { if (format.BeginZoneChar == '{') { sFormat += "{" + i++.ToString() + "}"; XValueFormat valueFormat = null; //{Node(Phone) - {@PhoneType} {@Phone}} StringZone[] zones = StringZones.SplitZone(format.ContentString, new char[,] { { '(', ')' }, { '{', '}' } }); if (zones.Length >= 2 && zones[0].BeginZoneChar == (char)0 && zones[1].BeginZoneChar == '(') { if (zones[0].String.ToLower() == "node") { valueFormat = new XValueFormat(); valueFormat.XPath = zones[1].ContentString; valueFormat.Values = new List<XValueFormat>(); string sFormat2 = ""; int i2 = 0; for (int j = 2; j < zones.Length; j++) { if (zones[j].BeginZoneChar == '{') { sFormat2 += "{" + i2++.ToString() + "}"; valueFormat.Values.Add(new XValueFormat() { XPath = zones[j].ContentString }); } else sFormat2 += zones[j].String; } valueFormat.Format = sFormat2; } } else valueFormat = new XValueFormat() { XPath = format.ContentString }; if (valueFormat != null) xf.gFormatValues.Add(valueFormat); } else sFormat += format.String; } xf.gsStringFormat = sFormat; } xf.SetOptions(xe.zAttribValue("option")); return xf; }
public static XFormat CreateXFormat(XElement xe) { XFormat xf = new XFormat(); xf.gsName = xe.Name.LocalName; xf.gsFormat = xe.zAttribValue("format"); if (xf.gsFormat != null) { xf.gFormats = StringZones.SplitZone(xf.gsFormat, new char[, ] { { '{', '}' } }); string sFormat = ""; int i = 0; xf.gFormatValues = new List <XValueFormat>(); foreach (StringZone format in xf.gFormats) { if (format.BeginZoneChar == '{') { sFormat += "{" + i++.ToString() + "}"; XValueFormat valueFormat = null; //{Node(Phone) - {@PhoneType} {@Phone}} StringZone[] zones = StringZones.SplitZone(format.ContentString, new char[, ] { { '(', ')' }, { '{', '}' } }); if (zones.Length >= 2 && zones[0].BeginZoneChar == (char)0 && zones[1].BeginZoneChar == '(') { if (zones[0].String.ToLower() == "node") { valueFormat = new XValueFormat(); valueFormat.XPath = zones[1].ContentString; valueFormat.Values = new List <XValueFormat>(); string sFormat2 = ""; int i2 = 0; for (int j = 2; j < zones.Length; j++) { if (zones[j].BeginZoneChar == '{') { sFormat2 += "{" + i2++.ToString() + "}"; valueFormat.Values.Add(new XValueFormat() { XPath = zones[j].ContentString }); } else { sFormat2 += zones[j].String; } } valueFormat.Format = sFormat2; } } else { valueFormat = new XValueFormat() { XPath = format.ContentString } }; if (valueFormat != null) { xf.gFormatValues.Add(valueFormat); } } else { sFormat += format.String; } } xf.gsStringFormat = sFormat; } xf.SetOptions(xe.zAttribValue("option")); return(xf); }