public static List<FormatItem> ParseFormatString(string formatString) { var l = new List<FormatItem>(); var split = formatString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in split) { FormatItem fi = new FormatItem(); var test = item.Replace("{", "").Replace("}", ""); if (test.Equals("literal", StringComparison.InvariantCultureIgnoreCase) || !Enum.TryParse<FormatItemType>(test, true, out fi.ItemType)) { fi.ItemType = FormatItemType.Literal; fi.LiteralValue = item; } l.Add(fi); } return l; }
public override void Initialise(BaseControl parent) { base.Initialise(parent); if (FormatItems == null) { FormatItems = new List<FormatItem>(); var fi = new FormatItem(); fi.ItemType = FormatItem.FormatItemType.Text; FormatItems.Add(fi); } }