Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / XPath / Internal / VariableQuery.cs / 1305376 / 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
- InfoCardService.cs
- QuerySettings.cs
- ExtendedProtectionPolicy.cs
- SubpageParagraph.cs
- IisTraceWebEventProvider.cs
- AtomEntry.cs
- ConnectionPointGlyph.cs
- WebConvert.cs
- ObjectCacheHost.cs
- StorageEndPropertyMapping.cs
- ObjectSet.cs
- TaskFileService.cs
- __ConsoleStream.cs
- HwndKeyboardInputProvider.cs
- ProfileEventArgs.cs
- PasswordDeriveBytes.cs
- RtfNavigator.cs
- MetadataCollection.cs
- TemplateComponentConnector.cs
- GetMemberBinder.cs
- MarkupCompilePass1.cs
- CorrelationResolver.cs
- TransformerTypeCollection.cs
- WebPartTransformer.cs
- NamespaceTable.cs
- WindowsFormsSectionHandler.cs
- TreeViewHitTestInfo.cs
- BoundPropertyEntry.cs
- EditorZoneDesigner.cs
- ResXResourceWriter.cs
- Span.cs
- TextTrailingCharacterEllipsis.cs
- PersonalizationProviderCollection.cs
- ImagingCache.cs
- SevenBitStream.cs
- ModelItemCollectionImpl.cs
- PersonalizationEntry.cs
- ToolboxItemLoader.cs
- PostBackTrigger.cs
- WindowsNonControl.cs
- RadioButton.cs
- AdornerDecorator.cs
- XmlSignificantWhitespace.cs
- SchemaElementLookUpTable.cs
- ThicknessConverter.cs
- TextServicesProperty.cs
- TreeNodeConverter.cs
- FormsAuthenticationCredentials.cs
- BuilderInfo.cs
- DataGridAddNewRow.cs
- XhtmlBasicCommandAdapter.cs
- PolyQuadraticBezierSegment.cs
- PrinterUnitConvert.cs
- RTLAwareMessageBox.cs
- ActivityBindForm.Designer.cs
- SqlEnums.cs
- DatatypeImplementation.cs
- RemotingException.cs
- TrustLevelCollection.cs
- DataGridAddNewRow.cs
- WrapPanel.cs
- CurrencyWrapper.cs
- ProjectionQueryOptionExpression.cs
- ResourceDictionary.cs
- WebPartManagerInternals.cs
- StoreUtilities.cs
- DataGridViewCellStyle.cs
- GeneratedView.cs
- ADRole.cs
- FontEditor.cs
- ThreadStaticAttribute.cs
- StringFreezingAttribute.cs
- ConditionalAttribute.cs
- Privilege.cs
- EntityViewGenerationAttribute.cs
- ToolStripLocationCancelEventArgs.cs
- FtpRequestCacheValidator.cs
- XmlBindingWorker.cs
- XsltConvert.cs
- PixelFormat.cs
- OdbcUtils.cs
- CodeLabeledStatement.cs
- ExtenderProvidedPropertyAttribute.cs
- InnerItemCollectionView.cs
- GroupStyle.cs
- ImpersonationContext.cs
- CompiledQueryCacheKey.cs
- SharedRuntimeState.cs
- DataGridViewColumnCollection.cs
- PropertyKey.cs
- Exceptions.cs
- ConstraintConverter.cs
- SafeLibraryHandle.cs
- WebPartConnectionCollection.cs
- diagnosticsswitches.cs
- DataSourceControl.cs
- CodeGeneratorOptions.cs
- CodeMethodReturnStatement.cs
- TraversalRequest.cs
- LocalizedNameDescriptionPair.cs