public ModelMap.ModelMap Parse(XDocument document, ModelMapCompilationReport report, bool isPartial) { var root = document.Root; var name = ""; var entity = ""; if (isPartial) { name = root.Attribute("name").Value; } else { var objectType = root.Attribute("objectType"); if (objectType == null) { throw new InvalidOperationException("No objectType specified"); } name = WorkflowObject.KeyFor(objectType.Value); entity = objectType.Value; } var map = new ModelMap.ModelMap(name, entity); parse(map, document, report, !isPartial); return(map); }
public ModelMap.ModelMap Parse(string filePath) { _logger.LogInfo("Parsing model map config at: " + filePath); using (var reader = new StreamReader(filePath)) { var doc = XDocument.Load(reader); var report = new ModelMapCompilationReport(); ModelMap.ModelMap config; try { config = Parse(doc, report, filePath.EndsWith(".partial.config")); } catch (Exception exc) { report.AddError(exc.Message); report.ReportTo(_logger); throw; } return(config); } }
private void parse(ModelMap.ModelMap map, XDocument document, ModelMapCompilationReport report, bool shouldAddDefaults) { var root = document.Root; var context = new ParsingContext(_services, report); map.AddInstruction(new BeginModelMap(map.Name)); context.PushObject(map); if (shouldAddDefaults) { addDefaults(map); } root .Elements() .Each(_ => _elementService.Visit(_, map, context)); context.PopObject(); map.AddInstruction(new EndModelMap()); }
public void Parse(ModelMap.ModelMap map, string filePath) { _logger.LogInfo("Parsing model map config at: " + filePath); using (var reader = new StreamReader(filePath)) { var doc = XDocument.Load(reader); var report = new ModelMapCompilationReport(); try { parse(map, doc, report, false); } catch (Exception exc) { report.AddError(exc.Message); report.ReportTo(_logger); throw; } } }