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
- x509store.cs
- SiteMembershipCondition.cs
- ConstNode.cs
- HttpHeaderCollection.cs
- TiffBitmapDecoder.cs
- ListViewDeletedEventArgs.cs
- WebPart.cs
- CodeExpressionCollection.cs
- SplashScreen.cs
- ByteConverter.cs
- QilValidationVisitor.cs
- RangeValidator.cs
- WindowsAuthenticationModule.cs
- TakeOrSkipWhileQueryOperator.cs
- StringFreezingAttribute.cs
- WsatServiceAddress.cs
- EditBehavior.cs
- QueryableDataSourceView.cs
- WindowsTab.cs
- DesignColumn.cs
- XmlParserContext.cs
- SqlCacheDependency.cs
- EncryptedReference.cs
- SQLRoleProvider.cs
- IndexOutOfRangeException.cs
- HttpConfigurationContext.cs
- TypeUtils.cs
- StringValidator.cs
- ServerProtocol.cs
- SmiRequestExecutor.cs
- keycontainerpermission.cs
- ButtonRenderer.cs
- ResourcesGenerator.cs
- PriorityItem.cs
- FieldTemplateFactory.cs
- HttpAsyncResult.cs
- JsonWriter.cs
- SplineQuaternionKeyFrame.cs
- XmlIgnoreAttribute.cs
- TitleStyle.cs
- StreamedFramingRequestChannel.cs
- WebFaultClientMessageInspector.cs
- DataGridViewUtilities.cs
- BaseConfigurationRecord.cs
- FastPropertyAccessor.cs
- PerformanceCounterPermissionEntryCollection.cs
- SystemIPv6InterfaceProperties.cs
- ExecutionProperties.cs
- IApplicationTrustManager.cs
- FormsAuthenticationUserCollection.cs
- XmlNodeReader.cs
- DataGridRow.cs
- unsafenativemethodstextservices.cs
- BasicHttpBindingCollectionElement.cs
- AppDomainManager.cs
- FormatterServices.cs
- CreateUserWizard.cs
- EventLogEntryCollection.cs
- AudioFormatConverter.cs
- Property.cs
- GlobalizationSection.cs
- NetStream.cs
- CachedTypeface.cs
- ItemsPanelTemplate.cs
- BeginStoryboard.cs
- IgnoreFlushAndCloseStream.cs
- TableLayoutRowStyleCollection.cs
- _PooledStream.cs
- StubHelpers.cs
- __TransparentProxy.cs
- ObjectManager.cs
- DataSourceSelectArguments.cs
- ModifierKeysConverter.cs
- RuleProcessor.cs
- TypeInitializationException.cs
- TreeNodeConverter.cs
- StrokeNode.cs
- FontInfo.cs
- HMACSHA384.cs
- CryptoKeySecurity.cs
- StaticFileHandler.cs
- ComponentSerializationService.cs
- VisualStyleRenderer.cs
- DiscriminatorMap.cs
- XmlText.cs
- NetNamedPipeBinding.cs
- TypeElementCollection.cs
- ViewKeyConstraint.cs
- XamlInt32CollectionSerializer.cs
- Setter.cs
- HttpHostedTransportConfiguration.cs
- ContentElement.cs
- FactoryMaker.cs
- SqlLiftIndependentRowExpressions.cs
- WorkflowHostingEndpoint.cs
- EventWaitHandleSecurity.cs
- Mouse.cs
- BuildProvider.cs
- GroupDescription.cs
- TypeBuilder.cs