// ============= Element Processing ================================== private void ReadElement() { // Accumulated text is enqueued a piece of content before this element EnqueueAnyText(); _hasKeyAttribute = false; // Empty Elements are by definition leaf elements and they // don't nest. So we don't need to stack this state. bool isEmptyTag = _xmlReader.IsEmptyElement; string prefix = _xmlReader.Prefix; string strippedName = _xmlReader.LocalName; if (XamlName.ContainsDot(strippedName)) { Debug.Assert(_xmlReader.NodeType == XmlNodeType.Element); XamlPropertyName name = XamlPropertyName.Parse(_xmlReader.Name, _xmlReader.NamespaceURI); if (_scannerStack.CurrentType == null) { throw LineInfo(new XamlParseException(SR.Get(SRID.ParentlessPropertyElement, _xmlReader.Name))); } ReadPropertyElement(name, _scannerStack.CurrentType, _scannerStack.CurrentTypeNamespace, isEmptyTag); } else { XamlName name = new XamlQualifiedName(prefix, strippedName); ReadObjectElement(name, isEmptyTag); } }
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; }
private void PreprocessAttributes() { if (this._xmlReader.MoveToFirstAttribute()) { List <XamlAttribute> attrList = new List <XamlAttribute>(); do { string longName = this._xmlReader.Name; string val = this._xmlReader.Value; XamlPropertyName propName = XamlPropertyName.Parse(longName); if (propName == null) { throw new XamlParseException(System.Xaml.SR.Get("InvalidXamlMemberName", new object[] { longName })); } XamlAttribute attr = new XamlAttribute(propName, val, this._xmlLineInfo); if (attr.Kind == ScannerAttributeKind.Namespace) { this.EnqueuePrefixDefinition(attr); } else { attrList.Add(attr); } }while (this._xmlReader.MoveToNextAttribute()); this.PreprocessForTypeArguments(attrList); if (attrList.Count > 0) { this._attributes = attrList; } this._xmlReader.MoveToElement(); } }
// ======== Attribute Processing ============================= private void PreprocessAttributes() { // Collect up all the attributes. bool b = _xmlReader.MoveToFirstAttribute(); if (!b) { return; } List <XamlAttribute> list = new List <XamlAttribute>(); do { string xmlName = _xmlReader.Name; string val = _xmlReader.Value; XamlPropertyName propName = XamlPropertyName.Parse(xmlName); if (propName == null) { throw new XamlParseException(SR.Get(SRID.InvalidXamlMemberName, xmlName)); } XamlAttribute attr = new XamlAttribute(propName, val, _xmlLineInfo); if (attr.Kind == ScannerAttributeKind.Namespace) { EnqueuePrefixDefinition(attr); } else { list.Add(attr); } b = _xmlReader.MoveToNextAttribute(); } while (b); PreprocessForTypeArguments(list); if (list.Count > 0) { _attributes = list; } // Restore the XML reader’s position to the Element after reading the // attributes so that the rest of the code can always assume it is on an Element _xmlReader.MoveToElement(); }
private void ReadElement() { this.EnqueueAnyText(); this._hasKeyAttribute = false; bool isEmptyElement = this._xmlReader.IsEmptyElement; string prefix = this._xmlReader.Prefix; string localName = this._xmlReader.LocalName; if (XamlName.ContainsDot(localName)) { XamlPropertyName name = XamlPropertyName.Parse(this._xmlReader.Name, this._xmlReader.NamespaceURI); if (this._scannerStack.CurrentType == null) { throw this.LineInfo(new XamlParseException(System.Xaml.SR.Get("ParentlessPropertyElement", new object[] { this._xmlReader.Name }))); } this.ReadPropertyElement(name, this._scannerStack.CurrentType, this._scannerStack.CurrentTypeNamespace, isEmptyElement); } else { XamlName name2 = new XamlQualifiedName(prefix, localName); this.ReadObjectElement(name2, isEmptyElement); } }
private void ResolvePropertyName(string longName) { XamlPropertyName propName = XamlPropertyName.Parse(longName); if (propName == null) { throw new ArgumentException(System.Xaml.SR.Get("MalformedPropertyName")); } XamlMember member = null; XamlType currentType = this._context.CurrentType; string currentTypeNamespace = this._context.CurrentTypeNamespace; if (propName.IsDotted) { member = this._context.GetDottedProperty(currentType, currentTypeNamespace, propName, false); } else { string attributeNamespace = this._context.GetAttributeNamespace(propName, this._tokenNamespace); XamlType tagType = this._context.CurrentType; member = this._context.GetNoDotAttributeProperty(tagType, propName, this._tokenNamespace, attributeNamespace, false); } this._tokenProperty = member; }