示例#1
0
文件: MeScanner.cs 项目: redmcg/wpf
        private void ResolveTypeName(string longName)
        {
            string       error;
            XamlTypeName typeName = XamlTypeName.ParseInternal(longName, _context.FindNamespaceByPrefix, out error);

            if (typeName == null)
            {
                throw new XamlParseException(this, error);
            }

            // In curly form, we search for TypeName + 'Extension' before TypeName
            string bareTypeName = typeName.Name;

            typeName.Name = typeName.Name + KnownStrings.Extension;
            XamlType xamlType = _context.GetXamlType(typeName, false);

            // This would be cleaner if we moved the Extension fallback logic out of XSC
            if (xamlType == null ||
                // Guard against Extension getting added twice
                (xamlType.UnderlyingType != null &&
                 KS.Eq(xamlType.UnderlyingType.Name, typeName.Name + KnownStrings.Extension)))
            {
                typeName.Name = bareTypeName;
                xamlType      = _context.GetXamlType(typeName, true);
            }

            _tokenXamlType  = xamlType;
            _tokenNamespace = typeName.Namespace;
        }
示例#2
0
        private bool ReadObjectElement_Object(string xmlns, string name, XamlScannerNode node)
        {
            if (IsXDataElement(xmlns, name))
            {
                // If XData don't Enqueue the <x:XData> node.
                // just queue the InnerXml as TEXT (w/ IsTextXML == true).
                // This will advance the "current" xml node to the </x:XData>
                // which will be skipped when we return and the main loop
                // Read()s to the "next" XmlNode.
                ReadInnerXDataSection();
                return(true);
            }

            IList <XamlTypeName> typeArgs = null;

            if (_typeArgumentAttribute != null)
            {
                string error;
                typeArgs = XamlTypeName.ParseListInternal(_typeArgumentAttribute.Value, _parserContext.FindNamespaceByPrefix, out error);
                if (typeArgs == null)
                {
                    throw new XamlParseException(_typeArgumentAttribute.LineNumber, _typeArgumentAttribute.LinePosition, error);
                }
            }
            XamlTypeName typeName = new XamlTypeName(xmlns, name, typeArgs);

            node.Type = _parserContext.GetXamlType(typeName, true);

            // Finish initializing the attributes in the context of the
            // current Element.
            PostprocessAttributes(node);

            if (_scannerStack.Depth > 0)
            {
                // Sub-elements (and Text) are the definition of Content
                _scannerStack.CurrentlyInContent = true;
            }

            if (!node.IsEmptyTag)
            {
                node.NodeType = ScannerNodeType.ELEMENT;
                _scannerStack.Push(node.Type, node.TypeNamespace);
            }
            else
            {
                node.NodeType = ScannerNodeType.EMPTYELEMENT;
            }
            return(false);
        }