// this might be getting called too many times since im not sure im caching the result
        private void ParseContentTemplate(TemplateRootNode templateRootNode, TemplateShell shell, ProcessedType processedType)
        {
            XElement root = shell.GetElementTemplateContent(processedType.templateAttr.templateId);

            if (root == null)
            {
                throw new TemplateNotFoundException(processedType.templateAttr.filePath, processedType.templateAttr.templateId);
            }

            IXmlLineInfo xmlLineInfo = root;

            StructList <AttributeDefinition> attributes = StructList <AttributeDefinition> .Get();

            StructList <AttributeDefinition> injectedAttributes = StructList <AttributeDefinition> .Get();

            ParseAttributes(shell, "Contents", root.Attributes(), attributes, injectedAttributes, out string genericTypeResolver, out string requireType);

            if (attributes.size == 0)
            {
                StructList <AttributeDefinition> .Release(ref attributes);
            }

            if (injectedAttributes.size == 0)
            {
                StructList <AttributeDefinition> .Release(ref injectedAttributes);
            }

            templateRootNode.attributes          = ValidateRootAttributes(shell.filePath, attributes);
            templateRootNode.lineInfo            = new TemplateLineInfo(xmlLineInfo.LineNumber, xmlLineInfo.LinePosition);
            templateRootNode.genericTypeResolver = genericTypeResolver;
            templateRootNode.requireType         = requireType; // always null I think
            ParseChildren(templateRootNode, templateRootNode, root.Nodes());
        }
Exemple #2
0
        public TemplateRootNode GetParsedTemplate(ProcessedType processedType)
        {
            TemplateAttribute templateAttr = processedType.templateAttr;

            templateAttr.filePath = ResolveTemplateFilePath(processedType);
            if (templateAttr.fullPathId == null)
            {
                templateAttr.fullPathId = templateAttr.templateId == null
                    ? templateAttr.filePath
                    : templateAttr.filePath + "#" + templateAttr.templateId;
            }

            Debug.Assert(templateAttr.fullPathId != null, "templateAttr.fullPathId != null");

            if (templateMap.TryGetValue(templateAttr.fullPathId, out LightList <TemplateRootNode> list))
            {
                for (int i = 0; i < list.size; i++)
                {
                    if (list.array[i].processedType.rawType == processedType.rawType)
                    {
                        return(list.array[i]);
                    }
                }

                TemplateRootNode retn = list[0].Clone(processedType);
                list.Add(retn);
                return(retn);
            }

            list = new LightList <TemplateRootNode>(2);

            templateMap[templateAttr.fullPathId] = list;

            TemplateDefinition templateDefinition = GetTemplateDefinition(processedType);

            templateAttr.source = templateDefinition.contents;

            TemplateShell shell = xmlTemplateParser.GetOuterTemplateShell(templateAttr);

            TemplateRootNode templateRootNode = new TemplateRootNode(templateAttr.templateId, shell, processedType, null, default)
            {
                tagName = processedType.tagName
            };

            list.Add(templateRootNode);

            xmlTemplateParser.Parse(templateRootNode, processedType);

            return(templateRootNode);
        }
Exemple #3
0
        internal void Parse(TemplateRootNode templateRootNode, ProcessedType processedType)
        {
            TemplateAttribute templateAttr = processedType.templateAttr;

            string filePath = templateAttr.filePath;

            if (parsedFiles.TryGetValue(filePath, out TemplateShell rootNode))
            {
                ParseContentTemplate(templateRootNode, rootNode, processedType);
                return;
            }

            TemplateShell shell = ParseOuterShell(templateAttr.filePath, templateAttr.source);

            parsedFiles.Add(filePath, shell);

            ParseContentTemplate(templateRootNode, shell, processedType);
        }
Exemple #4
0
 public RepeatNode(TemplateRootNode root, TemplateNode parent, ProcessedType processedType, StructList <AttributeDefinition> attributes, in TemplateLineInfo templateLineInfo) : base(root, parent, processedType, attributes, in templateLineInfo)
 public ExpandedTemplateNode(TemplateRootNode root, TemplateNode parent, ProcessedType processedType, StructList <AttributeDefinition> attributes, in TemplateLineInfo templateLineInfo)
Exemple #6
0
 public SlotNode(TemplateRootNode root, TemplateNode parent, ProcessedType processedType, StructList <AttributeDefinition> attributes, in TemplateLineInfo templateLineInfo, string slotName, SlotType slotType)