コード例 #1
0
        //  ========================== private ================================

        private XamlMember GetXamlAttributeProperty(XamlParserContext context, XamlPropertyName propName,
                                                    XamlType tagType, string tagNamespace, bool tagIsRoot)
        {
            XamlMember prop = null;
            string     ns   = context.GetAttributeNamespace(propName, tagNamespace);

            // No Namespace, == Unknown Property
            if (ns == null)
            {
                XamlMember unknownProperty;
                if (propName.IsDotted)
                {
                    XamlType attachedOwnerType = new XamlType(string.Empty, propName.OwnerName, null, context.SchemaContext);
                    unknownProperty = new XamlMember(propName.Name, attachedOwnerType, true /*isAttachable*/);
                }
                else
                {
                    unknownProperty = new XamlMember(propName.Name, tagType, false);
                }
                return(unknownProperty);
            }

            // Get the property (attached, normal, or directive)
            if (propName.IsDotted)
            {
                prop = context.GetDottedProperty(tagType, tagNamespace, propName, tagIsRoot);
            }
            else
            {
                prop = context.GetNoDotAttributeProperty(tagType, propName, tagNamespace, ns, tagIsRoot);
            }

            return(prop);
        }
コード例 #2
0
ファイル: MeScanner.cs プロジェクト: redmcg/wpf
        private void ResolvePropertyName(string longName)
        {
            XamlPropertyName propName = XamlPropertyName.Parse(longName);

            if (propName == null)
            {
                throw new ArgumentException(SR.Get(SRID.MalformedPropertyName));
            }

            XamlMember prop = null;
            XamlType   declaringType;
            XamlType   tagType      = _context.CurrentType;
            string     tagNamespace = _context.CurrentTypeNamespace;

            if (propName.IsDotted)
            {
                prop = _context.GetDottedProperty(tagType, tagNamespace, propName, false /*tagIsRoot*/);
            }
            // Regular property p
            else
            {
                string ns = _context.GetAttributeNamespace(propName, Namespace);
                declaringType = _context.CurrentType;
                prop          = _context.GetNoDotAttributeProperty(declaringType, propName, Namespace, ns, false /*tagIsRoot*/);
            }
            _tokenProperty = prop;
        }
コード例 #3
0
        private XamlMember GetXamlAttributeProperty(XamlParserContext context, XamlPropertyName propName, XamlType tagType, string tagNamespace, bool tagIsRoot)
        {
            string attributeNamespace = context.GetAttributeNamespace(propName, tagNamespace);

            if (attributeNamespace == null)
            {
                if (propName.IsDotted)
                {
                    return(new XamlMember(propName.Name, new XamlType(string.Empty, propName.OwnerName, null, context.SchemaContext), true));
                }
                return(new XamlMember(propName.Name, tagType, false));
            }
            if (propName.IsDotted)
            {
                return(context.GetDottedProperty(tagType, tagNamespace, propName, tagIsRoot));
            }
            return(context.GetNoDotAttributeProperty(tagType, propName, tagNamespace, attributeNamespace, tagIsRoot));
        }
コード例 #4
0
ファイル: XamlScanner.cs プロジェクト: xhowar/lindexi_gd
        private void ReadPropertyElement(XamlPropertyName name, XamlType tagType, string tagNamespace, bool isEmptyTag)
        {
            // <Button>   <== currentElement
            //   <FrameworkElement.Width>   <== FrameworkElement is ownerType

            XamlScannerNode node = new XamlScannerNode(_xmlLineInfo);

            // Attributes aren't allowed on property elements.
            // but if they are there we need to scan them so the
            // XamlParser can error, or whatever.
            // (don't want to skip them w/o error)
            PreprocessAttributes();

            // It is possible for an application to provide XML nodes via XmlNodeReader
            // where the URI is defined but there was no xmlns attribute for use to resolve against.
            // See app Paperboy
            Debug.Assert(_xmlReader.NodeType == XmlNodeType.Element);
            string     ownerNamespace = _xmlReader.NamespaceURI;
            XamlMember property       = null;

            bool tagIsRoot = _scannerStack.Depth == 1; // PEs are processed after frame is pushed

            property = _parserContext.GetDottedProperty(tagType, tagNamespace, name, tagIsRoot);

            node.Prefix        = name.Prefix;
            node.TypeNamespace = ownerNamespace;
            node.IsEmptyTag    = isEmptyTag;

            // node.Type is not set (this is a property)
            // so this processing does less.
            PostprocessAttributes(node);

            if (_scannerStack.Depth > 0)
            {
                // A property Element tag will be the end of content.
                // This also allows to to start content again.
                // That is an error, but at least the parser/scanner can
                // understand what is going on.
                _scannerStack.CurrentlyInContent = false;
            }

            node.PropertyElement = property;

            node.IsCtorForcingMember = !property.IsAttachable;

            if (!node.IsEmptyTag)
            {
                _scannerStack.CurrentProperty = node.PropertyElement;
                node.NodeType = ScannerNodeType.PROPERTYELEMENT;
            }
            else
            {
                node.NodeType = ScannerNodeType.EMPTYPROPERTYELEMENT;
            }

            _readNodesQueue.Enqueue(node);

            while (HaveUnprocessedAttributes)
            {
                EnqueueAnotherAttribute(isEmptyTag);
            }
        }