// Token: 0x06006C18 RID: 27672 RVA: 0x001F1AD4 File Offset: 0x001EFCD4 public override bool Equals(object other) { if (other == null) { return(false); } if (other.GetType() != base.GetType()) { return(false); } ElementTableKey elementTableKey = (ElementTableKey)other; return(string.CompareOrdinal(this.BaseName, elementTableKey.BaseName) == 0 && string.CompareOrdinal(this.XmlNamespace, elementTableKey.XmlNamespace) == 0); }
/// <summary> /// Equality test. /// </summary> public override bool Equals(object other) { if (other == null) { return(false); // Standard behavior. } if (other.GetType() != GetType()) { return(false); } // Note that because of the GetType() checking above, the casting must be valid. ElementTableKey otherElement = (ElementTableKey)other; return(String.CompareOrdinal(BaseName, otherElement.BaseName) == 0 && String.CompareOrdinal(XmlNamespace, otherElement.XmlNamespace) == 0); }
// Token: 0x06006C4D RID: 27725 RVA: 0x001F33F8 File Offset: 0x001F15F8 private IndexingContentUnit HandleFixedFormatTag(ElementTableKey elementFullName, out bool handled) { handled = true; if (!elementFullName.XmlNamespace.Equals(ElementTableKey.FixedMarkupNamespace, StringComparison.Ordinal)) { handled = false; return(null); } if (string.CompareOrdinal(elementFullName.BaseName, "Glyphs") == 0) { if (this._filterState == XamlFilter.FilterState.FindNextFlowUnit) { this.SkipCurrentElement(); return(null); } return(this.ProcessGlyphRun()); } else if (string.CompareOrdinal(elementFullName.BaseName, "FixedPage") == 0) { if (this._filterState == XamlFilter.FilterState.FindNextFlowUnit) { this.Push(this._defaultContentDescriptor); this._xamlReader.Read(); return(null); } return(this.ProcessFixedPage()); } else { if (string.CompareOrdinal(elementFullName.BaseName, "PageContent") != 0) { handled = false; return(null); } string attribute = this._xamlReader.GetAttribute("Source"); if (attribute != null) { this.SkipCurrentElement(); return(null); } this.Push(this._defaultContentDescriptor); 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); }
// 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); } }
// Token: 0x06006C49 RID: 27721 RVA: 0x001F310F File Offset: 0x001F130F private ContentDescriptor GetContentInformationAboutCustomElement(ElementTableKey customElement) { return(this._defaultContentDescriptor); }
/// <summary> /// If the current tag is one of Glyphs, FixedPage or PageContent, process it adequately /// and return the next content unit or null (if not supposed to return content from fixed format). /// Otherwise, set 'handled' to false to tell the caller we didn't do anything useful. /// </summary> private IndexingContentUnit HandleFixedFormatTag(ElementTableKey elementFullName, out bool handled) { handled = true; // Not true until we return, but this is the most convenient default. if (!elementFullName.XmlNamespace.Equals(ElementTableKey.FixedMarkupNamespace, StringComparison.Ordinal)) { handled = false; // Let caller handle that tag. return null; } if (String.CompareOrdinal(elementFullName.BaseName, _glyphRunName) == 0) { // Ignore glyph runs during flow pass over a FixedPage. if (_filterState == FilterState.FindNextFlowUnit) { SkipCurrentElement(); return null; } else { return ProcessGlyphRun(); } } if (String.CompareOrdinal(elementFullName.BaseName, _fixedPageName) == 0) { // Ignore FixedPage element (i.e. root element) during flow pass over a fixed page. if (_filterState == FilterState.FindNextFlowUnit) { Push(_defaultContentDescriptor); _xamlReader.Read(); return null; } else { return ProcessFixedPage(); } } if (String.CompareOrdinal(elementFullName.BaseName, _pageContentName) == 0) { // If the element has a Source attribute, any inlined content should be ignored. string sourceUri = _xamlReader.GetAttribute(_pageContentSourceAttribute); if (sourceUri != null) { SkipCurrentElement(); return null; } else { // Have NextContentUnit() look for content in descendants. Push( _defaultContentDescriptor); _xamlReader.Read(); return null; } } // No useful work was done. Report 'unhandled'. handled = false; return null; }
///<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; }
///<summary>Obtain a content descriptor for a custom element not found in the dictionary.</summary> /// <remarks> /// There is currently no general way of extracting information about custom elements, /// so the default descriptor is systematically returned. /// </remarks> private ContentDescriptor GetContentInformationAboutCustomElement(ElementTableKey customElement) { return _defaultContentDescriptor; }
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 the current tag is one of Glyphs, FixedPage or PageContent, process it adequately /// and return the next content unit or null (if not supposed to return content from fixed format). /// Otherwise, set 'handled' to false to tell the caller we didn't do anything useful. /// </summary> private IndexingContentUnit HandleFixedFormatTag(ElementTableKey elementFullName, out bool handled) { handled = true; // Not true until we return, but this is the most convenient default. if (!elementFullName.XmlNamespace.Equals(ElementTableKey.FixedMarkupNamespace, StringComparison.Ordinal)) { handled = false; // Let caller handle that tag. return(null); } if (String.CompareOrdinal(elementFullName.BaseName, _glyphRunName) == 0) { // Ignore glyph runs during flow pass over a FixedPage. if (_filterState == FilterState.FindNextFlowUnit) { SkipCurrentElement(); return(null); } else { return(ProcessGlyphRun()); } } if (String.CompareOrdinal(elementFullName.BaseName, _fixedPageName) == 0) { // Ignore FixedPage element (i.e. root element) during flow pass over a fixed page. if (_filterState == FilterState.FindNextFlowUnit) { Push(_defaultContentDescriptor); _xamlReader.Read(); return(null); } else { return(ProcessFixedPage()); } } if (String.CompareOrdinal(elementFullName.BaseName, _pageContentName) == 0) { // If the element has a Source attribute, any inlined content should be ignored. string sourceUri = _xamlReader.GetAttribute(_pageContentSourceAttribute); if (sourceUri != null) { SkipCurrentElement(); return(null); } else { // Have NextContentUnit() look for content in descendants. Push(_defaultContentDescriptor); _xamlReader.Read(); return(null); } } // No useful work was done. Report 'unhandled'. handled = false; return(null); }
///<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); }