// Token: 0x06006C4C RID: 27724 RVA: 0x001F33D4 File Offset: 0x001F15D4 private IndexingContentUnit HandleElementEnd() { ContentDescriptor contentDescriptor = this.Pop(); this._xamlReader.Read(); return(null); }
// Token: 0x06006C59 RID: 27737 RVA: 0x001F3788 File Offset: 0x001F1988 private void Push(ContentDescriptor contentDescriptor) { if (!contentDescriptor.IsInline) { this._expectingBlockStart = true; } this._contextStack.Push(contentDescriptor); }
// Token: 0x06006C5A RID: 27738 RVA: 0x001F37A8 File Offset: 0x001F19A8 private ContentDescriptor Pop() { ContentDescriptor contentDescriptor = (ContentDescriptor)this._contextStack.Pop(); if (!contentDescriptor.IsInline) { this._expectingBlockStart = true; } return(contentDescriptor); }
///<summary> /// On end of element, restore context data (pop, etc.) and look further. ///</summary> ///<remarks> /// Ancillary function of NextContentUnit. ///</remarks> private IndexingContentUnit HandleElementEnd() { // Pop current descriptor. ContentDescriptor item = Pop(); // Consume end-tag. _xamlReader.Read(); return(null); }
private ContentDescriptor Pop() { ContentDescriptor topOfStack = (ContentDescriptor)_contextStack.Pop(); // If we reach an end of block, we expect the next item to // start with a block separator. if (!topOfStack.IsInline) { _expectingBlockStart = true; } return(topOfStack); }
// Token: 0x06006C4A RID: 27722 RVA: 0x001F3118 File Offset: 0x001F1318 private IndexingContentUnit HandleTextData() { ContentDescriptor contentDescriptor = this.TopOfStack(); if (contentDescriptor != null) { IndexingContentUnit result = this.BuildIndexingContentUnit(this._xamlReader.Value, this.GetCurrentLcid()); this._xamlReader.Read(); return(result); } this._xamlReader.Read(); return(null); }
internal string DumpElementTable() { ICollection keys = _xamlElementContentDescriptorDictionary.Keys; ICollection values = _xamlElementContentDescriptorDictionary.Values; int length = keys.Count; ElementTableKey[] keyList = new ElementTableKey[length]; ContentDescriptor[] valueList = new ContentDescriptor[length]; keys.CopyTo(keyList, 0); values.CopyTo(valueList, 0); string result = ""; for (int i = 0; i < length; ++i) { result += string.Format("{0}: [{1} -> {2}]\n", i, keyList[i], valueList[i]); } return(result); }
///<summary> /// If current token is a text element, /// assume it can be part of its parent's content and return a chunk. ///</summary> ///<remarks> /// Ancillary function of NextContentUnit. ///</remarks> private IndexingContentUnit HandleTextData() { ContentDescriptor topOfStack = TopOfStack(); if (topOfStack != null) { // The descendants of elements with HasIndexableContent set to false get skipped. Debug.Assert(topOfStack.HasIndexableContent); // Return a chunk with appropriate block-break information. IndexingContentUnit result = BuildIndexingContentUnit(_xamlReader.Value, GetCurrentLcid()); _xamlReader.Read(); // Move past data just processed. return(result); } else { // Bad Xaml (no top-level element). The Xaml filter should at some point raise an exception. // Just to be safe, ignore all content when in this state. _xamlReader.Read(); // Skip data. return(null); } }
// Token: 0x06006C4B RID: 27723 RVA: 0x001F3164 File Offset: 0x001F1364 private IndexingContentUnit HandleElementStart() { ElementTableKey elementTableKey = new ElementTableKey(this._xamlReader.NamespaceURI, this._xamlReader.LocalName); string a; if (this.IsPrefixedPropertyName(elementTableKey.BaseName, out a)) { ContentDescriptor contentDescriptor = this.TopOfStack(); if (contentDescriptor == null) { this.SkipCurrentElement(); return(null); } bool flag = elementTableKey.XmlNamespace.Equals(ElementTableKey.XamlNamespace, StringComparison.Ordinal) && (a == contentDescriptor.ContentProp || a == contentDescriptor.TitleProp); if (!flag) { this.SkipCurrentElement(); return(null); } this.Push(new ContentDescriptor(flag, this.TopOfStack().IsInline, string.Empty, null)); this._xamlReader.Read(); return(null); } else { bool flag2; IndexingContentUnit indexingContentUnit = this.HandleFixedFormatTag(elementTableKey, out flag2); if (flag2) { return(indexingContentUnit); } Invariant.Assert(indexingContentUnit == null); ContentDescriptor contentDescriptor2 = (ContentDescriptor)this._xamlElementContentDescriptorDictionary[elementTableKey]; if (contentDescriptor2 == null) { if (elementTableKey.XmlNamespace.Equals(ElementTableKey.XamlNamespace, StringComparison.Ordinal)) { contentDescriptor2 = this._defaultContentDescriptor; } else if (elementTableKey.XmlNamespace.Equals("http://schemas.microsoft.com/winfx/2006/xaml", StringComparison.Ordinal)) { contentDescriptor2 = this._nonIndexableElementDescriptor; } else { contentDescriptor2 = this.GetContentInformationAboutCustomElement(elementTableKey); } this._xamlElementContentDescriptorDictionary.Add(elementTableKey, contentDescriptor2); } if (!contentDescriptor2.HasIndexableContent) { this.SkipCurrentElement(); return(null); } if (contentDescriptor2.TitleProp != null && (this._attributesToIgnore & XamlFilter.AttributesToIgnore.Title) == XamlFilter.AttributesToIgnore.None) { string propertyAsAttribute = this.GetPropertyAsAttribute(contentDescriptor2.TitleProp); if (propertyAsAttribute != null && propertyAsAttribute.Length > 0) { this._attributesToIgnore |= XamlFilter.AttributesToIgnore.Title; this._expectingBlockStart = true; IndexingContentUnit result = this.BuildIndexingContentUnit(propertyAsAttribute, this.GetCurrentLcid()); this._expectingBlockStart = true; return(result); } } if (contentDescriptor2.ContentProp != null && (this._attributesToIgnore & XamlFilter.AttributesToIgnore.Content) == XamlFilter.AttributesToIgnore.None) { string propertyAsAttribute2 = this.GetPropertyAsAttribute(contentDescriptor2.ContentProp); if (propertyAsAttribute2 != null && propertyAsAttribute2.Length > 0) { this._attributesToIgnore |= XamlFilter.AttributesToIgnore.Content; if (!contentDescriptor2.IsInline) { this._expectingBlockStart = true; } IndexingContentUnit result2 = this.BuildIndexingContentUnit(propertyAsAttribute2, this.GetCurrentLcid()); this._expectingBlockStart = !contentDescriptor2.IsInline; return(result2); } } this._attributesToIgnore = XamlFilter.AttributesToIgnore.None; if (this._xamlReader.IsEmptyElement) { if (!contentDescriptor2.IsInline) { this._expectingBlockStart = true; } this._xamlReader.Read(); return(null); } this.Push(contentDescriptor2); this._xamlReader.Read(); return(null); } }
private void Push(ContentDescriptor contentDescriptor) { if (!contentDescriptor.IsInline) { _expectingBlockStart = true; } _contextStack.Push(contentDescriptor); }
internal string DumpElementTable() { ICollection keys = _xamlElementContentDescriptorDictionary.Keys; ICollection values = _xamlElementContentDescriptorDictionary.Values; int length = keys.Count; ElementTableKey[] keyList = new ElementTableKey[length]; ContentDescriptor[] valueList = new ContentDescriptor[length]; keys.CopyTo(keyList, 0); values.CopyTo(valueList,0); string result = ""; for (int i = 0; i < length; ++i) { result += string.Format("{0}: [{1} -> {2}]\n", i, keyList[i], valueList[i]); } return result; }
///<summary> /// If current token is an element start, then, /// if appropriate, extract chunk text from an attribute /// else, record content information and recurse. ///</summary> ///<remarks> /// Ancillary function of NextContentUnit. ///</remarks> private IndexingContentUnit HandleElementStart() { ElementTableKey elementFullName = new ElementTableKey(_xamlReader.NamespaceURI, _xamlReader.LocalName); string propertyName; // Handle the case of a complex property (e.g. Button.Content). if (IsPrefixedPropertyName(elementFullName.BaseName, out propertyName)) { ContentDescriptor topOfStack = TopOfStack(); // Handle the semantically incorrect case of a compound property occurring at the root // by ignoring it totally. if (topOfStack == null) { SkipCurrentElement(); return(null); } // Index the text children of property elements only if they are content or title properties. bool elementIsIndexable = (elementFullName.XmlNamespace.Equals(ElementTableKey.XamlNamespace, StringComparison.Ordinal) && (propertyName == topOfStack.ContentProp || propertyName == topOfStack.TitleProp)); if (!elementIsIndexable) { // Skip element together with all its descendants. SkipCurrentElement(); return(null); } // Push descriptor, advance reader, and have caller look further. Push( new ContentDescriptor( elementIsIndexable, TopOfStack().IsInline, String.Empty, // has potential text content, but no content property null)); // no title property _xamlReader.Read(); return(null); } // Handle fixed-format markup in a special way (because assumptions for building // content descriptors don't work for these and they require actions beyond what // is stated in content descriptors). // Note: The elementFullyHandled boolean is required as the nextUnit returned can // be null in both cases - when element is fully handled and when its not. bool elementFullyHandled; IndexingContentUnit nextUnit = HandleFixedFormatTag(elementFullName, out elementFullyHandled); if (elementFullyHandled) { return(nextUnit); } else { // When HandleFixedFormatTag declines to handle a tag because it is not fixed-format, it // will return null. Invariant.Assert(nextUnit == null); } // Obtain a content descriptor for the current element. ContentDescriptor elementDescriptor = (ContentDescriptor)_xamlElementContentDescriptorDictionary[elementFullName]; if (elementDescriptor == null) { if (elementFullName.XmlNamespace.Equals(ElementTableKey.XamlNamespace, StringComparison.Ordinal)) { elementDescriptor = _defaultContentDescriptor; } else if (elementFullName.XmlNamespace.Equals(_inDocumentCodeURI, StringComparison.Ordinal)) { elementDescriptor = _nonIndexableElementDescriptor; } else { elementDescriptor = GetContentInformationAboutCustomElement(elementFullName); } _xamlElementContentDescriptorDictionary.Add(elementFullName, elementDescriptor); } // If the element has no indexable content, skip all its descendants. if (!elementDescriptor.HasIndexableContent) { SkipCurrentElement(); return(null); } // If appropriate, retrieve title from an attribute. string title = null; if (elementDescriptor.TitleProp != null && (_attributesToIgnore & AttributesToIgnore.Title) == 0) { title = GetPropertyAsAttribute(elementDescriptor.TitleProp); if (title != null && title.Length > 0) { // Leave the reader in its present state, but return the title as a block chunk, // and mark this attribute as processed. _attributesToIgnore |= AttributesToIgnore.Title; _expectingBlockStart = true; IndexingContentUnit titleContent = BuildIndexingContentUnit(title, GetCurrentLcid()); _expectingBlockStart = true; // Simulate a stack pop for a block element. return(titleContent); } } // If appropriate, retrieve content from an attribute. string content = null; if (elementDescriptor.ContentProp != null && (_attributesToIgnore & AttributesToIgnore.Content) == 0) { content = GetPropertyAsAttribute(elementDescriptor.ContentProp); if (content != null && content.Length > 0) { // Leave the reader in its present state, but mark the content attribute // as processed. _attributesToIgnore |= AttributesToIgnore.Content; // Create a new chunk with appropriate break data. if (!elementDescriptor.IsInline) { _expectingBlockStart = true; } IndexingContentUnit result = BuildIndexingContentUnit(content, GetCurrentLcid()); // Emulate a stack pop for the content attribute (which never gets pushed on the stack). _expectingBlockStart = !elementDescriptor.IsInline; return(result); } } // Reset the attribute flag, since we are going to change the reader's state. _attributesToIgnore = AttributesToIgnore.None; // Handle the special case of an empty element: no descendants, but a possible paragraph break. if (_xamlReader.IsEmptyElement) { if (!elementDescriptor.IsInline) { _expectingBlockStart = true; } // Have caller search for content past the tag. _xamlReader.Read(); return(null); } // Have caller look for content in descendants. Push(elementDescriptor); _xamlReader.Read(); // skip start-tag return(null); }