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
- ValueTypeFixupInfo.cs
- DesignBindingPicker.cs
- ProgressBarRenderer.cs
- ConditionedDesigner.cs
- WizardForm.cs
- Scene3D.cs
- DataServiceException.cs
- MouseButtonEventArgs.cs
- SimpleBitVector32.cs
- RequestCachingSection.cs
- Message.cs
- BitmapEffect.cs
- DecimalAnimationUsingKeyFrames.cs
- MonthChangedEventArgs.cs
- StreamMarshaler.cs
- DataGridViewRowsAddedEventArgs.cs
- DeploymentExceptionMapper.cs
- CommandValueSerializer.cs
- UnmanagedBitmapWrapper.cs
- TableDetailsRow.cs
- DBCommand.cs
- ColorTransformHelper.cs
- TreePrinter.cs
- EntityProviderFactory.cs
- GeneralTransform.cs
- User.cs
- SecurityChannel.cs
- UriTemplateTableMatchCandidate.cs
- RepeaterItem.cs
- EventLogPermission.cs
- PropertySourceInfo.cs
- SmiRequestExecutor.cs
- ControlCollection.cs
- PostBackTrigger.cs
- StrokeNode.cs
- TextDocumentView.cs
- SqlDataSourceCommandEventArgs.cs
- InertiaRotationBehavior.cs
- NavigationCommands.cs
- ConfigDefinitionUpdates.cs
- GZipStream.cs
- TextTrailingWordEllipsis.cs
- GeometryCollection.cs
- DataGridViewBindingCompleteEventArgs.cs
- PriorityItem.cs
- AdornerPresentationContext.cs
- ComponentEditorPage.cs
- UndoManager.cs
- SqlRecordBuffer.cs
- Vector3D.cs
- SecurityHeaderElementInferenceEngine.cs
- KnownBoxes.cs
- CodeDOMUtility.cs
- rsa.cs
- SystemPens.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- ToolStripCodeDomSerializer.cs
- XmlText.cs
- ObfuscationAttribute.cs
- PingReply.cs
- LinqDataView.cs
- MetadataItemSerializer.cs
- StaticSiteMapProvider.cs
- Size3D.cs
- ObjectDataSourceSelectingEventArgs.cs
- HtmlLiteralTextAdapter.cs
- XmlSerializationReader.cs
- NativeRightsManagementAPIsStructures.cs
- SHA384Managed.cs
- NullableDoubleMinMaxAggregationOperator.cs
- XmlAttribute.cs
- InputQueueChannelAcceptor.cs
- EntityCollection.cs
- ErrorHandler.cs
- VolatileEnlistmentMultiplexing.cs
- WebRequestModuleElement.cs
- TableTextElementCollectionInternal.cs
- FileAuthorizationModule.cs
- XPathNodeIterator.cs
- FormsAuthenticationTicket.cs
- TextTreeRootTextBlock.cs
- ScaleTransform.cs
- ToolStripItemBehavior.cs
- CatalogZoneBase.cs
- ContextProperty.cs
- codemethodreferenceexpression.cs
- GroupQuery.cs
- SystemResources.cs
- QilChoice.cs
- SqlWebEventProvider.cs
- StringDictionary.cs
- ButtonRenderer.cs
- PolyLineSegment.cs
- PartialCachingControl.cs
- PartialCachingAttribute.cs
- CompiledQuery.cs
- IisTraceWebEventProvider.cs
- IOException.cs
- InvariantComparer.cs
- FamilyMapCollection.cs