Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Xml / System / Xml / XPath / Internal / VariableQuery.cs / 1 / VariableQuery.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.Globalization; using System.Xml.Xsl; internal sealed class VariableQuery : ExtensionQuery { private IXsltContextVariable variable; public VariableQuery(string name, string prefix) : base(prefix, name) {} private VariableQuery(VariableQuery other) : base(other) { this.variable = other.variable; } public override void SetXsltContext(XsltContext context) { if (context == null) { throw XPathException.Create(Res.Xp_NoContext); } if (this.xsltContext != context) { xsltContext = context; variable = xsltContext.ResolveVariable(prefix, name); // Since null is allowed for ResolveFunction, allow it for ResolveVariable as well if (variable == null) { throw XPathException.Create(Res.Xp_UndefVar, QName); } } } public override object Evaluate(XPathNodeIterator nodeIterator) { if (xsltContext == null) { throw XPathException.Create(Res.Xp_NoContext); } return ProcessResult(variable.Evaluate(xsltContext)); } public override XPathResultType StaticType { get { if (variable != null) { // Temp. fix to overcome dependency on static type return GetXPathType(Evaluate(null)); } XPathResultType result = variable != null ? variable.VariableType : XPathResultType.Any; if (result == XPathResultType.Error) { // In v.1 we confused Error & Any so now for backward compatibility we should allow users to return any of them. result = XPathResultType.Any; } return result; } } public override XPathNodeIterator Clone() { return new VariableQuery(this); } public override void PrintQuery(XmlWriter w) { w.WriteStartElement(this.GetType().Name); w.WriteAttributeString("name", prefix.Length != 0 ? prefix + ':' + name : name); 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.Globalization; using System.Xml.Xsl; internal sealed class VariableQuery : ExtensionQuery { private IXsltContextVariable variable; public VariableQuery(string name, string prefix) : base(prefix, name) {} private VariableQuery(VariableQuery other) : base(other) { this.variable = other.variable; } public override void SetXsltContext(XsltContext context) { if (context == null) { throw XPathException.Create(Res.Xp_NoContext); } if (this.xsltContext != context) { xsltContext = context; variable = xsltContext.ResolveVariable(prefix, name); // Since null is allowed for ResolveFunction, allow it for ResolveVariable as well if (variable == null) { throw XPathException.Create(Res.Xp_UndefVar, QName); } } } public override object Evaluate(XPathNodeIterator nodeIterator) { if (xsltContext == null) { throw XPathException.Create(Res.Xp_NoContext); } return ProcessResult(variable.Evaluate(xsltContext)); } public override XPathResultType StaticType { get { if (variable != null) { // Temp. fix to overcome dependency on static type return GetXPathType(Evaluate(null)); } XPathResultType result = variable != null ? variable.VariableType : XPathResultType.Any; if (result == XPathResultType.Error) { // In v.1 we confused Error & Any so now for backward compatibility we should allow users to return any of them. result = XPathResultType.Any; } return result; } } public override XPathNodeIterator Clone() { return new VariableQuery(this); } public override void PrintQuery(XmlWriter w) { w.WriteStartElement(this.GetType().Name); w.WriteAttributeString("name", prefix.Length != 0 ? prefix + ':' + name : name); 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
- DesignerToolboxInfo.cs
- HiddenField.cs
- DataBoundControlHelper.cs
- NotificationContext.cs
- MessageEnumerator.cs
- DebugController.cs
- HtmlInputRadioButton.cs
- WindowsRegion.cs
- ItemsControl.cs
- IPHostEntry.cs
- WebDescriptionAttribute.cs
- SignedInfo.cs
- SizeAnimationUsingKeyFrames.cs
- TargetConverter.cs
- FileLoadException.cs
- DocumentApplication.cs
- ProcessHost.cs
- SpecialNameAttribute.cs
- MergablePropertyAttribute.cs
- RegexBoyerMoore.cs
- URIFormatException.cs
- DownloadProgressEventArgs.cs
- DiscriminatorMap.cs
- MeasurementDCInfo.cs
- Parameter.cs
- LinqExpressionNormalizer.cs
- UnicodeEncoding.cs
- PassportAuthenticationEventArgs.cs
- XmlSerializerVersionAttribute.cs
- BindableAttribute.cs
- GZipUtils.cs
- PreservationFileReader.cs
- AdornerPresentationContext.cs
- Native.cs
- MasterPageCodeDomTreeGenerator.cs
- QueryContinueDragEvent.cs
- Symbol.cs
- ResourcePool.cs
- SchemaLookupTable.cs
- entitydatasourceentitysetnameconverter.cs
- ZoneLinkButton.cs
- RewritingSimplifier.cs
- GenericParameterDataContract.cs
- InteropTrackingRecord.cs
- RemotingException.cs
- ObjectDataSourceMethodEditor.cs
- SatelliteContractVersionAttribute.cs
- MutexSecurity.cs
- DataRowChangeEvent.cs
- MemberInfoSerializationHolder.cs
- ColumnHeader.cs
- WebEventTraceProvider.cs
- Ppl.cs
- _SingleItemRequestCache.cs
- ContentPathSegment.cs
- CatalogZone.cs
- ProcessInfo.cs
- ListItem.cs
- WindowsTreeView.cs
- ReliableMessagingVersionConverter.cs
- XmlSerializer.cs
- WebPermission.cs
- DeviceContext2.cs
- _PooledStream.cs
- ComboBox.cs
- SegmentInfo.cs
- DeleteBookmarkScope.cs
- SaveFileDialog.cs
- InvokeWebServiceDesigner.cs
- ComponentResourceManager.cs
- MethodBuilderInstantiation.cs
- Trace.cs
- DesignTimeVisibleAttribute.cs
- TableCellAutomationPeer.cs
- ForeignKeyConstraint.cs
- COMException.cs
- DataSourceSelectArguments.cs
- EntityContainerAssociationSet.cs
- UniqueCodeIdentifierScope.cs
- IndexOutOfRangeException.cs
- ImageMapEventArgs.cs
- XmlWriterTraceListener.cs
- PluggableProtocol.cs
- WebSysDisplayNameAttribute.cs
- Expression.cs
- PropertyMappingExceptionEventArgs.cs
- SmtpReplyReaderFactory.cs
- TreeSet.cs
- ValidationManager.cs
- NullRuntimeConfig.cs
- SchemaNotation.cs
- CustomWebEventKey.cs
- MailHeaderInfo.cs
- ListBoxAutomationPeer.cs
- DynamicExpression.cs
- GenericWebPart.cs
- Line.cs
- BaseTemplateCodeDomTreeGenerator.cs
- MimePart.cs
- webclient.cs