コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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;
                }
            }
        }