public TypedMarkupData Parse(string registeredPrefix, bool isArray, string value, ITemplate tpl) { if (isArray) { StringBuilder sb = new StringBuilder(); sb.Append("new Person[] {"); Person[] persons; if (value.Trim() != "") { string[] split = value.Split('|'); persons = new Person[split.Length]; for (int i = 0; i < split.Length; i++) { StringPersonPair v = ParseSingle(split[i]); if (v == null) throw new TemplateErrorException(ParserUtils.MakeTypedMarkupErrorMessage(registeredPrefix, isArray, value)); sb.Append(i > 0 ? ", " : " "); persons[i] = v.p; sb.Append(v.s); } } else persons = new Person[0]; sb.Append(" }"); return new TypedMarkupData(sb.ToString(), delegate() { return persons; }); } else { StringPersonPair v = ParseSingle(value); if (v == null) throw new TemplateErrorException(ParserUtils.MakeTypedMarkupErrorMessage(registeredPrefix, isArray, value)); return new TypedMarkupData(v.s, delegate { return v.p; }); } }
public StringPersonPair(string s, Person p) { this.s = s; this.p = p; }