/// <summary> /// override of WriteDefTag /// </summary> public override void WriteDefTag(XamlDefTagNode xamlDefTagNode) { if (!_pass2) { _compiler.ProcessDefinitionNamespace(xamlDefTagNode); } else { // loop through until after the end of the current definition tag is reached. while (!xamlDefTagNode.IsEmptyElement && xamlDefTagNode.XmlReader.NodeType != XmlNodeType.EndElement) { xamlDefTagNode.XmlReader.Read(); } xamlDefTagNode.XmlReader.Read(); } }
internal void ProcessDefinitionNamespace(XamlDefTagNode xamlDefTagNode) { bool exitLoop = false; XmlReader xmlReader = xamlDefTagNode.XmlReader; string LocalName = xmlReader.LocalName; bool isEmptyElement = xamlDefTagNode.IsEmptyElement; bool isProcessingCodeTag = false; do { XmlNodeType currNodeType = xmlReader.NodeType; switch (currNodeType) { case XmlNodeType.Element: { if (isProcessingCodeTag) { ThrowCompilerException(SRID.DefnTagsCannotBeNested, DefinitionNSPrefix, LocalName, xmlReader.LocalName); } switch (LocalName) { case CODETAG: isProcessingCodeTag = true; if (!IsCodeNeeded) { ThrowCompilerException(SRID.MissingClassDefinitionForCodeTag, _ccRoot.ElementName, DefinitionNSPrefix, SourceFileInfo.RelativeSourceFilePath + XAML); } bool moreAttributes = xmlReader.MoveToFirstAttribute(); while (moreAttributes) { string attributeNamespaceUri = xmlReader.LookupNamespace(xmlReader.Prefix); if (!attributeNamespaceUri.Equals(XamlReaderHelper.DefinitionNamespaceURI) || !xmlReader.LocalName.Equals(XamlReaderHelper.DefinitionUid)) { ThrowCompilerException(SRID.AttributeNotAllowedOnCodeTag, xmlReader.Name, DefinitionNSPrefix, CODETAG); } moreAttributes = xmlReader.MoveToNextAttribute(); } break; default: ThrowCompilerException(SRID.UnknownDefinitionTag, DefinitionNSPrefix, LocalName); break; } // if an empty element do a Reader to // get to the next node and then exit if (isEmptyElement) { xmlReader.Read(); exitLoop = true; } break; } case XmlNodeType.EndElement: { xmlReader.Read(); exitLoop = true; break; } case XmlNodeType.CDATA: case XmlNodeType.Text: { IXmlLineInfo xmlLineInfo = xmlReader as IXmlLineInfo; int lineNumber = 0; if (null != xmlLineInfo) { lineNumber = xmlLineInfo.LineNumber; } if (LocalName.Equals(CODETAG)) { AddCodeSnippet(xmlReader.Value, lineNumber); } else { ThrowCompilerException(SRID.IllegalCDataTextScoping, DefinitionNSPrefix, LocalName, (currNodeType == XmlNodeType.CDATA ? "a CDATA section" : "text content")); } break; } } } while (!exitLoop && xmlReader.Read()); }
/// <summary> /// WriteDefTag occurs when a x:Whatever tag is encountered. /// Superclasses must interprete this since the base class doesn't understand /// any of them. /// </summary> public virtual void WriteDefTag(XamlDefTagNode xamlDefTagNode) { ThrowException(SRID.ParserDefTag, xamlDefTagNode.Value, xamlDefTagNode.LineNumber, xamlDefTagNode.LinePosition); }