Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / XsltOld / TemplateManager.cs / 1 / 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
- DataGridView.cs
- CultureTableRecord.cs
- WebServiceClientProxyGenerator.cs
- PlacementWorkspace.cs
- BaseInfoTable.cs
- SqlServices.cs
- _ListenerAsyncResult.cs
- CommandExpr.cs
- TargetControlTypeAttribute.cs
- ToolStripDropDownClosedEventArgs.cs
- SchemaNames.cs
- ValidatorCollection.cs
- CacheOutputQuery.cs
- ImportContext.cs
- StorageMappingItemLoader.cs
- InstalledFontCollection.cs
- Matrix.cs
- ExpressionsCollectionConverter.cs
- BrowserInteropHelper.cs
- NativeMethods.cs
- ObfuscationAttribute.cs
- XhtmlBasicLiteralTextAdapter.cs
- ProxyFragment.cs
- DataServicePagingProviderWrapper.cs
- DefinitionUpdate.cs
- TrimSurroundingWhitespaceAttribute.cs
- DiscoveryDocumentLinksPattern.cs
- TextClipboardData.cs
- OAVariantLib.cs
- FontInfo.cs
- ADMembershipUser.cs
- ValidatedControlConverter.cs
- HttpPostLocalhostServerProtocol.cs
- ThemeDirectoryCompiler.cs
- CriticalExceptions.cs
- MediaTimeline.cs
- CheckBox.cs
- TypefaceMetricsCache.cs
- FloaterBaseParaClient.cs
- CapabilitiesSection.cs
- WmlControlAdapter.cs
- MemberAssignmentAnalysis.cs
- FamilyMapCollection.cs
- ReaderContextStackData.cs
- TextProviderWrapper.cs
- CompoundFileStreamReference.cs
- OneOfTypeConst.cs
- SetStoryboardSpeedRatio.cs
- PipelineModuleStepContainer.cs
- SqlInternalConnectionTds.cs
- TransportContext.cs
- Size3DValueSerializer.cs
- AutomationInteropProvider.cs
- DecoderExceptionFallback.cs
- MediaTimeline.cs
- MenuStrip.cs
- DataGridViewCheckBoxCell.cs
- DetailsViewActionList.cs
- SqlExpressionNullability.cs
- ColorInterpolationModeValidation.cs
- EndpointConfigContainer.cs
- BoolExpression.cs
- Decoder.cs
- RectangleF.cs
- SignedInfo.cs
- ProfileInfo.cs
- _AcceptOverlappedAsyncResult.cs
- SplashScreen.cs
- WorkflowServiceInstance.cs
- DataGridViewTextBoxEditingControl.cs
- UrlMappingsSection.cs
- EmptyControlCollection.cs
- Style.cs
- ActivityStateRecord.cs
- WebPartZone.cs
- MobileControlsSectionHelper.cs
- _Connection.cs
- DiagnosticsConfiguration.cs
- VisualBasicImportReference.cs
- BamlTreeNode.cs
- OleDbErrorCollection.cs
- ValidationErrorEventArgs.cs
- NativeMethods.cs
- Bezier.cs
- DbProviderSpecificTypePropertyAttribute.cs
- DCSafeHandle.cs
- SurrogateSelector.cs
- ControlPaint.cs
- CodeTryCatchFinallyStatement.cs
- UdpConstants.cs
- XmlSchemaDocumentation.cs
- ProviderException.cs
- ExeContext.cs
- KeyConverter.cs
- BooleanStorage.cs
- SqlCommand.cs
- Part.cs
- BitmapImage.cs
- DesignerValidationSummaryAdapter.cs
- NullableLongSumAggregationOperator.cs