Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / XPath / Internal / NodeFunctions.cs / 1 / NodeFunctions.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; using FT = MS.Internal.Xml.XPath.Function.FunctionType; internal sealed class NodeFunctions : ValueQuery { Query arg = null; FT funcType; XsltContext xsltContext; public NodeFunctions(FT funcType, Query arg) { this.funcType = funcType; this.arg = arg; } public override void SetXsltContext(XsltContext context){ this.xsltContext = context.Whitespace ? context : null; if (arg != null) { arg.SetXsltContext(context); } } private XPathNavigator EvaluateArg(XPathNodeIterator context) { if (arg == null) { return context.Current; } arg.Evaluate(context); return arg.Advance(); } public override object Evaluate(XPathNodeIterator context) { XPathNavigator argVal; switch (funcType) { case FT.FuncPosition: return (double)context.CurrentPosition; case FT.FuncLast: return (double)context.Count; case FT.FuncNameSpaceUri: argVal = EvaluateArg(context); if (argVal != null) { return argVal.NamespaceURI; } break; case FT.FuncLocalName: argVal = EvaluateArg(context); if (argVal != null) { return argVal.LocalName; } break; case FT.FuncName : argVal = EvaluateArg(context); if (argVal != null) { return argVal.Name; } break; case FT.FuncCount: arg.Evaluate(context); int count = 0; if (xsltContext != null) { XPathNavigator nav; while ((nav = arg.Advance()) != null) { if (nav.NodeType != XPathNodeType.Whitespace || xsltContext.PreserveWhitespace(nav)) { count++; } } } else { while (arg.Advance() != null) { count++; } } return (double) count; } return string.Empty; } public override XPathResultType StaticType { get { return Function.ReturnTypes[(int)funcType]; } } public override XPathNodeIterator Clone() { NodeFunctions method = new NodeFunctions(funcType, Clone(arg)); method.xsltContext = this.xsltContext; return method; } public override void PrintQuery(XmlWriter w) { w.WriteStartElement(this.GetType().Name); w.WriteAttributeString("name", funcType.ToString()); if (arg != null) { arg.PrintQuery(w); } w.WriteEndElement(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PrintDialog.cs
- ForeignConstraint.cs
- SerializationAttributes.cs
- WebPartManager.cs
- GenericTypeParameterBuilder.cs
- Material.cs
- MissingFieldException.cs
- DataRelation.cs
- SqlColumnizer.cs
- X509CertificateCollection.cs
- XPathEmptyIterator.cs
- InputLanguage.cs
- Schedule.cs
- _NestedMultipleAsyncResult.cs
- CommandSet.cs
- ContextMenu.cs
- PropertyValueChangedEvent.cs
- ConditionValidator.cs
- DrawingAttributesDefaultValueFactory.cs
- Help.cs
- FileDialogPermission.cs
- ConfigXmlCDataSection.cs
- WebPartVerb.cs
- Tablet.cs
- ValidationHelpers.cs
- XmlCodeExporter.cs
- SamlAssertionKeyIdentifierClause.cs
- PresentationAppDomainManager.cs
- Model3DGroup.cs
- SymbolTable.cs
- DefaultAssemblyResolver.cs
- WMIInterop.cs
- SerializeAbsoluteContext.cs
- ExpressionTextBox.xaml.cs
- PageTheme.cs
- FileSecurity.cs
- TraceContextEventArgs.cs
- ContentPosition.cs
- AuthenticationServiceManager.cs
- StringValueSerializer.cs
- smtpconnection.cs
- InvalidateEvent.cs
- ByteStorage.cs
- SchemaConstraints.cs
- SHA512Managed.cs
- CommunicationException.cs
- DatatypeImplementation.cs
- HebrewNumber.cs
- CodeNamespace.cs
- EntityContainerEntitySetDefiningQuery.cs
- TextCompositionManager.cs
- FragmentQueryKB.cs
- PenThread.cs
- LinkLabel.cs
- PropertyValueUIItem.cs
- XmlnsCompatibleWithAttribute.cs
- HandlerBase.cs
- AuthenticationServiceManager.cs
- _ConnectOverlappedAsyncResult.cs
- COM2Properties.cs
- VectorCollectionConverter.cs
- ServicePerformanceCounters.cs
- StringHandle.cs
- PolicyValidationException.cs
- SmiTypedGetterSetter.cs
- GetLedgerEntryForRecipientRequest.cs
- KeyValueSerializer.cs
- BaseUriWithWildcard.cs
- HandlerWithFactory.cs
- EncoderReplacementFallback.cs
- CalendarDateChangedEventArgs.cs
- DesignTableCollection.cs
- Int32KeyFrameCollection.cs
- SqlNotificationRequest.cs
- ColorConvertedBitmap.cs
- Hashtable.cs
- MasterPageBuildProvider.cs
- FormatSettings.cs
- WebRequestModuleElementCollection.cs
- WindowsServiceCredential.cs
- EmptyStringExpandableObjectConverter.cs
- WebPartZone.cs
- BitmapMetadataEnumerator.cs
- Int32EqualityComparer.cs
- XmlSchemaGroupRef.cs
- UnitControl.cs
- CorrelationTokenTypeConvertor.cs
- BaseTemplateBuildProvider.cs
- DataServiceQueryProvider.cs
- _NestedMultipleAsyncResult.cs
- SuppressMergeCheckAttribute.cs
- SynchronizingStream.cs
- ExpressionEditor.cs
- RegionIterator.cs
- PanelDesigner.cs
- HMACMD5.cs
- TakeOrSkipWhileQueryOperator.cs
- LambdaCompiler.Unary.cs
- SystemGatewayIPAddressInformation.cs
- InvalidProgramException.cs