Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Xml / System / Xml / XPath / Internal / ExtensionQuery.cs / 5 / ExtensionQuery.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace MS.Internal.Xml.XPath { using System; using System.Xml; using System.Xml.Xsl; using System.Xml.XPath; using System.Diagnostics; using System.Globalization; using System.Collections; internal abstract class ExtensionQuery : Query { protected string prefix; protected string name; protected XsltContext xsltContext; private ResetableIterator queryIterator; public ExtensionQuery(string prefix, string name) : base() { this.prefix = prefix; this.name = name; } protected ExtensionQuery(ExtensionQuery other) : base(other) { this.prefix = other.prefix; this.name = other.name; this.xsltContext = other.xsltContext; this.queryIterator = (ResetableIterator)Clone(other.queryIterator); } public override void Reset() { if (queryIterator != null) { queryIterator.Reset(); } } public override XPathNavigator Current { get { if (queryIterator == null) { throw XPathException.Create(Res.Xp_NodeSetExpected); } if (queryIterator.CurrentPosition == 0) { Advance(); } return queryIterator.Current; } } public override XPathNavigator Advance() { if (queryIterator == null) { throw XPathException.Create(Res.Xp_NodeSetExpected); } if (queryIterator.MoveNext()) { return queryIterator.Current; } return null; } public override int CurrentPosition { get { if (queryIterator != null) { return queryIterator.CurrentPosition; } return 0; } } protected object ProcessResult(object value) { if (value is string ) return value; if (value is double ) return value; if (value is bool ) return value; if (value is XPathNavigator) return value; if (value is Int32 ) return (double)(Int32)value; if (value == null) { queryIterator = XPathEmptyIterator.Instance; return this; // We map null to NodeSet to let $null/foo work well. } ResetableIterator resetable = value as ResetableIterator; if (resetable != null) { // We need Clone() value because variable may be used several times // and they shouldn't queryIterator = (ResetableIterator)resetable.Clone(); return this; } XPathNodeIterator nodeIterator = value as XPathNodeIterator; if (nodeIterator != null) { queryIterator = new XPathArrayIterator(nodeIterator); return this; } IXPathNavigable navigable = value as IXPathNavigable; if(navigable != null) { return navigable.CreateNavigator(); } if (value is Int16 ) return (double)(Int16)value; if (value is Int64 ) return (double)(Int64)value; if (value is UInt32) return (double)(UInt32)value; if (value is UInt16) return (double)(UInt16)value; if (value is UInt64) return (double)(UInt64)value; if (value is Single) return (double)(Single)value; if (value is Decimal) return (double)(Decimal)value; return value.ToString(); } protected string QName { get { return prefix.Length != 0 ? prefix + ":" + name : name; } } public override int Count { get { return queryIterator == null ? 1 : queryIterator.Count; } } public override XPathResultType StaticType { get { return XPathResultType.Any; } } } } // 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.Xsl; using System.Xml.XPath; using System.Diagnostics; using System.Globalization; using System.Collections; internal abstract class ExtensionQuery : Query { protected string prefix; protected string name; protected XsltContext xsltContext; private ResetableIterator queryIterator; public ExtensionQuery(string prefix, string name) : base() { this.prefix = prefix; this.name = name; } protected ExtensionQuery(ExtensionQuery other) : base(other) { this.prefix = other.prefix; this.name = other.name; this.xsltContext = other.xsltContext; this.queryIterator = (ResetableIterator)Clone(other.queryIterator); } public override void Reset() { if (queryIterator != null) { queryIterator.Reset(); } } public override XPathNavigator Current { get { if (queryIterator == null) { throw XPathException.Create(Res.Xp_NodeSetExpected); } if (queryIterator.CurrentPosition == 0) { Advance(); } return queryIterator.Current; } } public override XPathNavigator Advance() { if (queryIterator == null) { throw XPathException.Create(Res.Xp_NodeSetExpected); } if (queryIterator.MoveNext()) { return queryIterator.Current; } return null; } public override int CurrentPosition { get { if (queryIterator != null) { return queryIterator.CurrentPosition; } return 0; } } protected object ProcessResult(object value) { if (value is string ) return value; if (value is double ) return value; if (value is bool ) return value; if (value is XPathNavigator) return value; if (value is Int32 ) return (double)(Int32)value; if (value == null) { queryIterator = XPathEmptyIterator.Instance; return this; // We map null to NodeSet to let $null/foo work well. } ResetableIterator resetable = value as ResetableIterator; if (resetable != null) { // We need Clone() value because variable may be used several times // and they shouldn't queryIterator = (ResetableIterator)resetable.Clone(); return this; } XPathNodeIterator nodeIterator = value as XPathNodeIterator; if (nodeIterator != null) { queryIterator = new XPathArrayIterator(nodeIterator); return this; } IXPathNavigable navigable = value as IXPathNavigable; if(navigable != null) { return navigable.CreateNavigator(); } if (value is Int16 ) return (double)(Int16)value; if (value is Int64 ) return (double)(Int64)value; if (value is UInt32) return (double)(UInt32)value; if (value is UInt16) return (double)(UInt16)value; if (value is UInt64) return (double)(UInt64)value; if (value is Single) return (double)(Single)value; if (value is Decimal) return (double)(Decimal)value; return value.ToString(); } protected string QName { get { return prefix.Length != 0 ? prefix + ":" + name : name; } } public override int Count { get { return queryIterator == null ? 1 : queryIterator.Count; } } public override XPathResultType StaticType { get { return XPathResultType.Any; } } } } // 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
- BreakSafeBase.cs
- MdImport.cs
- DataObject.cs
- AutoGeneratedFieldProperties.cs
- MemberNameValidator.cs
- PathFigureCollection.cs
- SoapAttributes.cs
- InputScopeNameConverter.cs
- LocationSectionRecord.cs
- DataGridComboBoxColumn.cs
- OracleBoolean.cs
- RootBrowserWindowProxy.cs
- WindowsRebar.cs
- StructuredType.cs
- webeventbuffer.cs
- BamlRecords.cs
- BidPrivateBase.cs
- DependencyObject.cs
- ConnectionManagementElementCollection.cs
- DragDeltaEventArgs.cs
- ProxyElement.cs
- TreeViewImageIndexConverter.cs
- TextWriterEngine.cs
- QuestionEventArgs.cs
- Timer.cs
- ListView.cs
- RenderTargetBitmap.cs
- RootProfilePropertySettingsCollection.cs
- OperationResponse.cs
- NetworkStream.cs
- CheckableControlBaseAdapter.cs
- TextTrailingWordEllipsis.cs
- SettingsSection.cs
- PngBitmapDecoder.cs
- DateTimeParse.cs
- CategoryValueConverter.cs
- EncryptedPackage.cs
- RectangleConverter.cs
- DataGridColumnFloatingHeader.cs
- SqlErrorCollection.cs
- GeneralTransform2DTo3D.cs
- HostExecutionContextManager.cs
- EdmEntityTypeAttribute.cs
- DockPatternIdentifiers.cs
- UIServiceHelper.cs
- ParallelDesigner.cs
- StoreItemCollection.Loader.cs
- GroupBoxRenderer.cs
- Equal.cs
- AutomationIdentifier.cs
- HostedHttpContext.cs
- UndoManager.cs
- MetadataCache.cs
- Label.cs
- DesignBindingConverter.cs
- FileVersion.cs
- AmbiguousMatchException.cs
- DataGrid.cs
- ProcessModelInfo.cs
- DbModificationCommandTree.cs
- SecurityContext.cs
- IDReferencePropertyAttribute.cs
- ParameterCollection.cs
- MediaCommands.cs
- TextureBrush.cs
- DoubleAnimationClockResource.cs
- ToggleButton.cs
- BezierSegment.cs
- XmlFormatExtensionPointAttribute.cs
- MetafileHeaderWmf.cs
- OrderByLifter.cs
- OleCmdHelper.cs
- _NTAuthentication.cs
- NativeMethodsOther.cs
- SqlFunctionAttribute.cs
- DataObjectMethodAttribute.cs
- WebPartZoneBase.cs
- _AutoWebProxyScriptEngine.cs
- xmlsaver.cs
- TextEditorCharacters.cs
- HttpRuntime.cs
- HasCopySemanticsAttribute.cs
- ConversionHelper.cs
- NameValuePair.cs
- DesignerRegionCollection.cs
- InvalidAsynchronousStateException.cs
- TypeUtil.cs
- TagPrefixInfo.cs
- InternalCache.cs
- XmlReaderSettings.cs
- AssemblyBuilder.cs
- SafeRightsManagementPubHandle.cs
- Page.cs
- PropertyEmitterBase.cs
- DnsPermission.cs
- CleanUpVirtualizedItemEventArgs.cs
- TemplatePartAttribute.cs
- WmlListAdapter.cs
- EntityDataSourceDataSelectionPanel.cs
- RSAPKCS1KeyExchangeFormatter.cs