public override void ExitGenericModel([NotNull] GenericModelContext context)
        {
            var list = new List <Models.IModelObject>();

            foreach (var item in context._smodels)
            {
                var sm = SingleModels.Get(item);
                list.Add(sm);
            }

            var TopLevelModel = new Models.SingleModel("@" + context.ID().GetText(), list)
            {
                Path = path.GetPath()
            };

            // check for doubles
            var existing = Collector.SingleModels.FirstOrDefault(p => p.Name == TopLevelModel.Name);

            if (existing != null)
            {
                existing.Value.AddRange(TopLevelModel.Value);
            }
            else
            {
                Collector.SingleModels.Add(TopLevelModel);
            }
            GraphElements.Add(TopLevelModel.Path, new GraphElement(TopLevelModel.Path, TopLevelModel));
            path.Pop();

            base.ExitGenericModel(context);
        }
        public override void ExitSinglemodel([NotNull] SinglemodelContext context)
        {
            var fullpath = path.GetPath();

            path.Pop();
            logger.Trace("Exit singlemodel {0}", fullpath);

            var obj = ObjProps.Get(context.obj());

            var model = new Models.SingleModel(context.ID().GetText(), obj);

            var orderby = ObjOrderByProps.Get(context.obj());

            model.Path = fullpath;
            model.OrderBy.AddRange(orderby);

            //model.Section = CurrentSection;
            if (context.inherits() != null)
            {
                model.Inherits     = true;
                model.InheritsFrom = context.inherits().ID().GetText();
            }
            string obs = "";

            logger.Trace("Single model = {0}{1}{2}",
                         model.Name,
                         context.inherits() != null ? " : " + model.InheritsFrom : "",
                         orderby.Any() ? " / " + orderby.Aggregate(obs, (f, run) => obs += run + ", ") : "");

            GraphElements.Add(model.Path, new GraphElement(model.Path, model));
            SingleModels.Put(context, model);
            base.ExitSinglemodel(context);
        }