public static ModelSubmit Parse(IModel owner, XElement el) { var submit = new ModelSubmit { OwningForm = owner }; foreach (var field in el.Descendants("field")) { var key = field.Attribute("name").Value; var value = field.Attribute("value").Value; submit.Values.Add(new SubmitField { Key = key, Value = value }); } var submittedTime = el.Attribute("time").Value; try { submit.Time = DateTime.Parse(submittedTime, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind); } catch (FormatException) { submit.Time = DateTime.Parse(submittedTime, CultureInfo.InvariantCulture); } return(submit); }
public static IEnumerable <ModelSubmit> LoadSubmits(string name) { var model = ModelsFacade.GetModel(name); var dir = Path.Combine(ModelsFacade.RootPath, name, "Submits"); var files = Directory.GetFiles(dir, "*.xml"); return(files.Select(XElement.Load).Select(f => ModelSubmit.Parse(model, f))); }