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
- XmlDataFileEditor.cs
- DerivedKeySecurityToken.cs
- TableRowCollection.cs
- Typeface.cs
- ToolStripComboBox.cs
- XPathParser.cs
- ScalarOps.cs
- GuidTagList.cs
- ColorConverter.cs
- ProtocolViolationException.cs
- DataKeyArray.cs
- ClientApiGenerator.cs
- BrowserCapabilitiesFactoryBase.cs
- MergablePropertyAttribute.cs
- datacache.cs
- AssemblyAttributes.cs
- SoapConverter.cs
- Mouse.cs
- TrackBar.cs
- AsymmetricKeyExchangeDeformatter.cs
- CompiledRegexRunner.cs
- SessionParameter.cs
- PositiveTimeSpanValidatorAttribute.cs
- ConfigXmlAttribute.cs
- MappedMetaModel.cs
- TimestampInformation.cs
- ApplicationInfo.cs
- XPathPatternParser.cs
- ComboBoxItem.cs
- UrlMappingCollection.cs
- OutputCacheProfile.cs
- StringUtil.cs
- Deserializer.cs
- MetadataArtifactLoaderComposite.cs
- ISAPIWorkerRequest.cs
- ProcessDesigner.cs
- MimeTypePropertyAttribute.cs
- WebContext.cs
- EntityClientCacheKey.cs
- Int64AnimationUsingKeyFrames.cs
- HeaderUtility.cs
- GroupItem.cs
- ProcessHostMapPath.cs
- PersonalizationState.cs
- DropShadowEffect.cs
- GeneralTransform2DTo3D.cs
- ValueOfAction.cs
- ConnectionManagementSection.cs
- EventLogEntry.cs
- IndexerNameAttribute.cs
- PlainXmlSerializer.cs
- KnownIds.cs
- PeerSecurityHelpers.cs
- MatrixValueSerializer.cs
- OutputScopeManager.cs
- InternalConfigRoot.cs
- ClientConfigurationSystem.cs
- DataGridItem.cs
- ProcessThread.cs
- Animatable.cs
- AuthenticatedStream.cs
- RegexGroupCollection.cs
- ObjectQuery.cs
- PointCollection.cs
- XmlWrappingWriter.cs
- UniqueConstraint.cs
- WebPartUserCapability.cs
- ButtonStandardAdapter.cs
- WebPartDisplayMode.cs
- AccessibleObject.cs
- odbcmetadatafactory.cs
- Wrapper.cs
- RtType.cs
- InternalMappingException.cs
- DirectoryLocalQuery.cs
- MouseButtonEventArgs.cs
- URLMembershipCondition.cs
- HttpStreamFormatter.cs
- SqlMultiplexer.cs
- Emitter.cs
- GridItemProviderWrapper.cs
- InternalTypeHelper.cs
- EnumBuilder.cs
- CodeTypeDeclarationCollection.cs
- BitStack.cs
- DataGridViewCellMouseEventArgs.cs
- DbConnectionFactory.cs
- BuilderPropertyEntry.cs
- ListBoxItem.cs
- ExpandSegmentCollection.cs
- elementinformation.cs
- SendKeys.cs
- NumericPagerField.cs
- FilteredAttributeCollection.cs
- CompilerCollection.cs
- Properties.cs
- GeneralTransform3D.cs
- StateManagedCollection.cs
- SoapObjectInfo.cs
- DefaultBindingPropertyAttribute.cs