Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- Padding.cs
- SqlError.cs
- ReaderWriterLockWrapper.cs
- BridgeDataRecord.cs
- ResourceDefaultValueAttribute.cs
- EastAsianLunisolarCalendar.cs
- keycontainerpermission.cs
- OrthographicCamera.cs
- SQLMoneyStorage.cs
- TextTreeExtractElementUndoUnit.cs
- GlyphRunDrawing.cs
- AnnotationResourceCollection.cs
- RestHandler.cs
- EmptyCollection.cs
- XomlCompilerError.cs
- ChangeConflicts.cs
- DragDrop.cs
- PointCollectionValueSerializer.cs
- SamlAssertionKeyIdentifierClause.cs
- Point.cs
- CallbackValidatorAttribute.cs
- GridViewRowEventArgs.cs
- SkewTransform.cs
- WindowsListViewGroupSubsetLink.cs
- SystemNetworkInterface.cs
- DataGridViewLinkColumn.cs
- XmlSchemaSequence.cs
- EventMappingSettingsCollection.cs
- HostedElements.cs
- MaterialGroup.cs
- Pen.cs
- ConnectorDragDropGlyph.cs
- TemplateColumn.cs
- TreeBuilder.cs
- HtmlShimManager.cs
- RecognizerInfo.cs
- ControlPropertyNameConverter.cs
- LinkClickEvent.cs
- PersonalizablePropertyEntry.cs
- BufferedWebEventProvider.cs
- SQLMoney.cs
- SoapEnumAttribute.cs
- PenThreadPool.cs
- ConstraintCollection.cs
- ReceiveContent.cs
- ActiveXContainer.cs
- PropertyPathWorker.cs
- ColorKeyFrameCollection.cs
- LinkedList.cs
- Latin1Encoding.cs
- DataBinder.cs
- SafeLocalAllocation.cs
- SharedPerformanceCounter.cs
- TemplateParser.cs
- TransformedBitmap.cs
- TokenBasedSetEnumerator.cs
- TraceUtility.cs
- ControlPropertyNameConverter.cs
- Label.cs
- CustomBindingElement.cs
- DummyDataSource.cs
- SingleStorage.cs
- ContextBase.cs
- WsatConfiguration.cs
- SelfSignedCertificate.cs
- ImageFormatConverter.cs
- OdbcInfoMessageEvent.cs
- _emptywebproxy.cs
- MessageBodyMemberAttribute.cs
- _TimerThread.cs
- XsdDuration.cs
- UpdateRecord.cs
- MetadataProperty.cs
- DataPagerCommandEventArgs.cs
- RadioButtonPopupAdapter.cs
- StateWorkerRequest.cs
- EdmPropertyAttribute.cs
- Int32EqualityComparer.cs
- SerialPinChanges.cs
- PerformanceCountersElement.cs
- SqlNamer.cs
- brushes.cs
- DateTimeEditor.cs
- HostProtectionException.cs
- TlsSspiNegotiation.cs
- EventlogProvider.cs
- ToolStripDropDownItem.cs
- XmlUtil.cs
- ChannelEndpointElementCollection.cs
- SmiContextFactory.cs
- PropertyRef.cs
- ReferencedAssembly.cs
- ObjectQueryState.cs
- Menu.cs
- OleDbPermission.cs
- NumberFormatInfo.cs
- QueryContinueDragEventArgs.cs
- UnicastIPAddressInformationCollection.cs
- MethodImplAttribute.cs
- ExpressionParser.cs