Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Xml / System / Xml / XPath / Internal / UnionExpr.cs / 1 / UnionExpr.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace MS.Internal.Xml.XPath { using System; using System.Xml; using System.Xml.XPath; using System.Diagnostics; using System.Xml.Xsl; internal sealed class UnionExpr : Query { internal Query qy1, qy2; private bool advance1, advance2; private XPathNavigator currentNode; private XPathNavigator nextNode; public UnionExpr(Query query1, Query query2) { this.qy1 = query1; this.qy2 = query2; this.advance1 = true; this.advance2 = true; } private UnionExpr(UnionExpr other) : base(other) { this.qy1 = Clone(other.qy1); this.qy2 = Clone(other.qy2); this.advance1 = other.advance1; this.advance2 = other.advance2; this.currentNode = Clone(other.currentNode); this.nextNode = Clone(other.nextNode); } public override void Reset() { qy1.Reset(); qy2.Reset(); advance1 = true; advance2 = true; nextNode = null; } public override void SetXsltContext(XsltContext xsltContext) { qy1.SetXsltContext(xsltContext); qy2.SetXsltContext(xsltContext); } public override object Evaluate(XPathNodeIterator context) { qy1.Evaluate(context); qy2.Evaluate(context); advance1 = true; advance2 = true; nextNode = null; base.ResetCount(); return this; } private XPathNavigator ProcessSamePosition(XPathNavigator result){ currentNode = result; advance1 = advance2 = true; return result; } private XPathNavigator ProcessBeforePosition(XPathNavigator res1, XPathNavigator res2){ nextNode = res2; advance2 = false; advance1 = true; currentNode = res1; return res1; } private XPathNavigator ProcessAfterPosition(XPathNavigator res1, XPathNavigator res2){ nextNode = res1; advance1 = false; advance2 = true; currentNode = res2; return res2; } public override XPathNavigator Advance() { XPathNavigator res1, res2; XmlNodeOrder order = 0; if (advance1) { res1 = qy1.Advance(); } else { res1 = nextNode; } if (advance2) { res2 = qy2.Advance(); } else { res2 = nextNode; } if (res1 != null && res2 != null) { order = CompareNodes(res1, res2); } else if (res2 == null) { advance1 = true; advance2 = false; currentNode = res1; nextNode = null; return res1; } else { advance1 = false; advance2 = true; currentNode = res2; nextNode = null; return res2; } if (order == XmlNodeOrder.Before) { return ProcessBeforePosition(res1, res2); } else if (order == XmlNodeOrder.After) { return ProcessAfterPosition(res1, res2); } else { // BugBug. In case of Unknown we sorting as the same. return ProcessSamePosition(res1); } } public override XPathNavigator MatchNode(XPathNavigator xsltContext) { if (xsltContext != null) { XPathNavigator result = qy1.MatchNode(xsltContext); if (result != null) { return result; } return qy2.MatchNode(xsltContext); } return null; } public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } } public override XPathNodeIterator Clone() { return new UnionExpr(this); } public override XPathNavigator Current { get { return currentNode; } } public override int CurrentPosition { get { throw new InvalidOperationException(); } } public override void PrintQuery(XmlWriter w) { w.WriteStartElement(this.GetType().Name); if (qy1 != null) { qy1.PrintQuery(w); } if (qy2 != null) { qy2.PrintQuery(w); } w.WriteEndElement(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace MS.Internal.Xml.XPath { using System; using System.Xml; using System.Xml.XPath; using System.Diagnostics; using System.Xml.Xsl; internal sealed class UnionExpr : Query { internal Query qy1, qy2; private bool advance1, advance2; private XPathNavigator currentNode; private XPathNavigator nextNode; public UnionExpr(Query query1, Query query2) { this.qy1 = query1; this.qy2 = query2; this.advance1 = true; this.advance2 = true; } private UnionExpr(UnionExpr other) : base(other) { this.qy1 = Clone(other.qy1); this.qy2 = Clone(other.qy2); this.advance1 = other.advance1; this.advance2 = other.advance2; this.currentNode = Clone(other.currentNode); this.nextNode = Clone(other.nextNode); } public override void Reset() { qy1.Reset(); qy2.Reset(); advance1 = true; advance2 = true; nextNode = null; } public override void SetXsltContext(XsltContext xsltContext) { qy1.SetXsltContext(xsltContext); qy2.SetXsltContext(xsltContext); } public override object Evaluate(XPathNodeIterator context) { qy1.Evaluate(context); qy2.Evaluate(context); advance1 = true; advance2 = true; nextNode = null; base.ResetCount(); return this; } private XPathNavigator ProcessSamePosition(XPathNavigator result){ currentNode = result; advance1 = advance2 = true; return result; } private XPathNavigator ProcessBeforePosition(XPathNavigator res1, XPathNavigator res2){ nextNode = res2; advance2 = false; advance1 = true; currentNode = res1; return res1; } private XPathNavigator ProcessAfterPosition(XPathNavigator res1, XPathNavigator res2){ nextNode = res1; advance1 = false; advance2 = true; currentNode = res2; return res2; } public override XPathNavigator Advance() { XPathNavigator res1, res2; XmlNodeOrder order = 0; if (advance1) { res1 = qy1.Advance(); } else { res1 = nextNode; } if (advance2) { res2 = qy2.Advance(); } else { res2 = nextNode; } if (res1 != null && res2 != null) { order = CompareNodes(res1, res2); } else if (res2 == null) { advance1 = true; advance2 = false; currentNode = res1; nextNode = null; return res1; } else { advance1 = false; advance2 = true; currentNode = res2; nextNode = null; return res2; } if (order == XmlNodeOrder.Before) { return ProcessBeforePosition(res1, res2); } else if (order == XmlNodeOrder.After) { return ProcessAfterPosition(res1, res2); } else { // BugBug. In case of Unknown we sorting as the same. return ProcessSamePosition(res1); } } public override XPathNavigator MatchNode(XPathNavigator xsltContext) { if (xsltContext != null) { XPathNavigator result = qy1.MatchNode(xsltContext); if (result != null) { return result; } return qy2.MatchNode(xsltContext); } return null; } public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } } public override XPathNodeIterator Clone() { return new UnionExpr(this); } public override XPathNavigator Current { get { return currentNode; } } public override int CurrentPosition { get { throw new InvalidOperationException(); } } public override void PrintQuery(XmlWriter w) { w.WriteStartElement(this.GetType().Name); if (qy1 != null) { qy1.PrintQuery(w); } if (qy2 != null) { qy2.PrintQuery(w); } w.WriteEndElement(); } } } // 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
- StylusPointProperty.cs
- TraceUtility.cs
- SubstitutionResponseElement.cs
- TraceLevelHelper.cs
- RegistryDataKey.cs
- TextServicesContext.cs
- DataSourceCache.cs
- Atom10FormatterFactory.cs
- Transform.cs
- TryCatch.cs
- ValidateNames.cs
- XhtmlMobileTextWriter.cs
- PageTheme.cs
- RegistryPermission.cs
- TiffBitmapDecoder.cs
- RankException.cs
- GCHandleCookieTable.cs
- InvalidAsynchronousStateException.cs
- SoapIgnoreAttribute.cs
- FileLevelControlBuilderAttribute.cs
- EntityPropertyMappingAttribute.cs
- PermissionListSet.cs
- TableLayoutPanelCodeDomSerializer.cs
- HwndKeyboardInputProvider.cs
- MediaEntryAttribute.cs
- Crc32Helper.cs
- UTF7Encoding.cs
- PocoEntityKeyStrategy.cs
- OutArgumentConverter.cs
- Line.cs
- WindowsListViewItem.cs
- ConditionalAttribute.cs
- SqlDependencyUtils.cs
- XmlTextReader.cs
- ZoomPercentageConverter.cs
- SoapUnknownHeader.cs
- AppearanceEditorPart.cs
- ViewSimplifier.cs
- TextWriterTraceListener.cs
- InstanceNormalEvent.cs
- TypeToken.cs
- COM2IPerPropertyBrowsingHandler.cs
- CodeSnippetCompileUnit.cs
- EditingCoordinator.cs
- SQLDateTime.cs
- SettingsPropertyWrongTypeException.cs
- EntityDataSourceState.cs
- Missing.cs
- UInt64.cs
- UnsafeNativeMethods.cs
- ServiceMetadataExtension.cs
- SizeLimitedCache.cs
- AdapterUtil.cs
- DataGridViewSelectedColumnCollection.cs
- FixedSOMPageConstructor.cs
- Substitution.cs
- ByteStack.cs
- MultiSelectRootGridEntry.cs
- JulianCalendar.cs
- CheckableControlBaseAdapter.cs
- ChtmlMobileTextWriter.cs
- ResXResourceReader.cs
- LicenseProviderAttribute.cs
- SqlRowUpdatedEvent.cs
- SelfIssuedTokenFactoryCredential.cs
- Decorator.cs
- FirstMatchCodeGroup.cs
- TransformerInfoCollection.cs
- StateElement.cs
- ResourceFallbackManager.cs
- RuntimeConfigLKG.cs
- PKCS1MaskGenerationMethod.cs
- WebPartPersonalization.cs
- SecurityDescriptor.cs
- SelectionRange.cs
- ConstraintStruct.cs
- Visual3DCollection.cs
- TaiwanLunisolarCalendar.cs
- ReceiveContent.cs
- SoapAttributes.cs
- FixedSOMElement.cs
- TextContainerChangedEventArgs.cs
- ListenerConnectionDemuxer.cs
- DocumentApplicationJournalEntryEventArgs.cs
- PublishLicense.cs
- DependencyObjectPropertyDescriptor.cs
- MaterializeFromAtom.cs
- HttpApplication.cs
- BinaryReader.cs
- ConstraintEnumerator.cs
- SchemaNotation.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- DataControlButton.cs
- CommentAction.cs
- WebPartPersonalization.cs
- DataGridViewCellCancelEventArgs.cs
- DependencyProperty.cs
- ImpersonateTokenRef.cs
- ImageDrawing.cs
- Message.cs