Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / XmlUtils / System / Xml / Xsl / XsltOld / TemplateManager.cs / 1305376 / TemplateManager.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml.Xsl.XsltOld { using Res = System.Xml.Utils.Res; using System; using System.Diagnostics; using System.Xml; using System.Xml.XPath; using System.Collections; internal class TemplateManager { private XmlQualifiedName mode; internal ArrayList templates; private Stylesheet stylesheet; // Owning stylesheet private class TemplateComparer : IComparer { public int Compare(object x, object y) { Debug.Assert(x != null && x is TemplateAction); Debug.Assert(y != null && y is TemplateAction); TemplateAction tx = (TemplateAction) x; TemplateAction ty = (TemplateAction) y; Debug.Assert(! Double.IsNaN(tx.Priority)); Debug.Assert(! Double.IsNaN(ty.Priority)); if (tx.Priority == ty.Priority) { Debug.Assert(tx.TemplateId != ty.TemplateId || tx == ty); return tx.TemplateId - ty.TemplateId; } else { return tx.Priority > ty.Priority ? 1 : -1; } } } private static TemplateComparer s_TemplateComparer = new TemplateComparer(); internal XmlQualifiedName Mode { get { return this.mode; } } internal TemplateManager(Stylesheet stylesheet, XmlQualifiedName mode) { this.mode = mode; this.stylesheet = stylesheet; } internal void AddTemplate(TemplateAction template) { Debug.Assert(template != null); Debug.Assert( ((object) this.mode == (object) template.Mode) || (template.Mode == null && this.mode.Equals(XmlQualifiedName.Empty)) || this.mode.Equals(template.Mode) ); if (this.templates == null) { this.templates = new ArrayList(); } this.templates.Add(template); } internal void ProcessTemplates() { if (this.templates != null) { this.templates.Sort(s_TemplateComparer); } } internal TemplateAction FindTemplate(Processor processor, XPathNavigator navigator) { if (this.templates == null) { return null; } Debug.Assert(this.templates != null); for (int templateIndex = this.templates.Count - 1; templateIndex >= 0 ; templateIndex --) { TemplateAction action = (TemplateAction) this.templates[templateIndex]; int matchKey = action.MatchKey; if (matchKey != Compiler.InvalidQueryKey) { if (processor.Matches(navigator, matchKey)) { return action; } } } return null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml.Xsl.XsltOld { using Res = System.Xml.Utils.Res; using System; using System.Diagnostics; using System.Xml; using System.Xml.XPath; using System.Collections; internal class TemplateManager { private XmlQualifiedName mode; internal ArrayList templates; private Stylesheet stylesheet; // Owning stylesheet private class TemplateComparer : IComparer { public int Compare(object x, object y) { Debug.Assert(x != null && x is TemplateAction); Debug.Assert(y != null && y is TemplateAction); TemplateAction tx = (TemplateAction) x; TemplateAction ty = (TemplateAction) y; Debug.Assert(! Double.IsNaN(tx.Priority)); Debug.Assert(! Double.IsNaN(ty.Priority)); if (tx.Priority == ty.Priority) { Debug.Assert(tx.TemplateId != ty.TemplateId || tx == ty); return tx.TemplateId - ty.TemplateId; } else { return tx.Priority > ty.Priority ? 1 : -1; } } } private static TemplateComparer s_TemplateComparer = new TemplateComparer(); internal XmlQualifiedName Mode { get { return this.mode; } } internal TemplateManager(Stylesheet stylesheet, XmlQualifiedName mode) { this.mode = mode; this.stylesheet = stylesheet; } internal void AddTemplate(TemplateAction template) { Debug.Assert(template != null); Debug.Assert( ((object) this.mode == (object) template.Mode) || (template.Mode == null && this.mode.Equals(XmlQualifiedName.Empty)) || this.mode.Equals(template.Mode) ); if (this.templates == null) { this.templates = new ArrayList(); } this.templates.Add(template); } internal void ProcessTemplates() { if (this.templates != null) { this.templates.Sort(s_TemplateComparer); } } internal TemplateAction FindTemplate(Processor processor, XPathNavigator navigator) { if (this.templates == null) { return null; } Debug.Assert(this.templates != null); for (int templateIndex = this.templates.Count - 1; templateIndex >= 0 ; templateIndex --) { TemplateAction action = (TemplateAction) this.templates[templateIndex]; int matchKey = action.MatchKey; if (matchKey != Compiler.InvalidQueryKey) { if (processor.Matches(navigator, matchKey)) { return action; } } } return null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DescendantOverDescendantQuery.cs
- RegexTypeEditor.cs
- activationcontext.cs
- Point3DCollection.cs
- ValidatorCollection.cs
- ForeignKeyConstraint.cs
- WebPartConnectionsCancelEventArgs.cs
- ModifierKeysValueSerializer.cs
- AnimationClock.cs
- WorkflowMarkupSerializationProvider.cs
- TreeNodeConverter.cs
- MarkerProperties.cs
- FormatterServices.cs
- FixedPage.cs
- ChtmlPhoneCallAdapter.cs
- ColumnHeaderConverter.cs
- _UriSyntax.cs
- UserControl.cs
- ExpandedWrapper.cs
- TypedTableHandler.cs
- TemplateControlBuildProvider.cs
- AnnotationStore.cs
- EntityDataReader.cs
- ModelUtilities.cs
- PublisherMembershipCondition.cs
- Brush.cs
- _emptywebproxy.cs
- BrushValueSerializer.cs
- WebPartVerbsEventArgs.cs
- MethodToken.cs
- GraphicsPath.cs
- XmlUtil.cs
- ItemDragEvent.cs
- TreeViewItemAutomationPeer.cs
- AppDomain.cs
- Transform3DCollection.cs
- WSHttpBindingCollectionElement.cs
- XmlBoundElement.cs
- SafeFileHandle.cs
- UInt64Converter.cs
- Point4DValueSerializer.cs
- RectAnimationUsingKeyFrames.cs
- CodeSnippetStatement.cs
- HttpContext.cs
- StringSorter.cs
- _ListenerResponseStream.cs
- RootBrowserWindowAutomationPeer.cs
- ProcessProtocolHandler.cs
- WindowsPen.cs
- ToolStripDropDownItem.cs
- XmlLangPropertyAttribute.cs
- DateTimeValueSerializer.cs
- SelectionItemPattern.cs
- _RequestCacheProtocol.cs
- EpmSyndicationContentSerializer.cs
- OletxCommittableTransaction.cs
- AnnotationAdorner.cs
- CallbackDebugElement.cs
- VBIdentifierTrimConverter.cs
- RuleSetDialog.Designer.cs
- ConfigurationStrings.cs
- UxThemeWrapper.cs
- CookieHandler.cs
- Source.cs
- VectorCollection.cs
- DeclaredTypeValidator.cs
- Internal.cs
- SecUtil.cs
- Cursor.cs
- DesignerImageAdapter.cs
- CodeTypeReferenceExpression.cs
- QueryExpr.cs
- Journal.cs
- UnsafeNativeMethods.cs
- RadioButtonPopupAdapter.cs
- Internal.cs
- RoleGroupCollectionEditor.cs
- ResetableIterator.cs
- Terminate.cs
- ListBase.cs
- ReceiveSecurityHeaderEntry.cs
- StyleTypedPropertyAttribute.cs
- DSASignatureDeformatter.cs
- XPathParser.cs
- SettingsPropertyWrongTypeException.cs
- PropertyGridCommands.cs
- Classification.cs
- StringPropertyBuilder.cs
- TimeoutTimer.cs
- COM2EnumConverter.cs
- ResponseBodyWriter.cs
- SecurityTokenProvider.cs
- PersonalizationProvider.cs
- CommentEmitter.cs
- WindowProviderWrapper.cs
- ChangePassword.cs
- TrustExchangeException.cs
- HtmlCommandAdapter.cs
- PersistenceParticipant.cs
- DefinitionUpdate.cs