Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Query / InternalTrees / NodeCounter.cs / 1305376 / NodeCounter.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Diagnostics;
using System.Data.Common;
using md=System.Data.Metadata.Edm;
namespace System.Data.Query.InternalTrees
{
///
/// Counts the number of nodes in a tree
///
internal class NodeCounter : BasicOpVisitorOfT
{
///
/// Public entry point - Calculates the nubmer of nodes in the given subTree
///
///
///
internal static int Count(Node subTree)
{
NodeCounter counter = new NodeCounter();
return counter.VisitNode(subTree);
}
///
/// Common processing for all node types
/// Count = 1 (self) + count of children
///
///
///
protected override int VisitDefault(Node n)
{
int count = 1;
foreach (Node child in n.Children)
{
count += VisitNode(child);
}
return count;
}
}
}
// 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
- ValueQuery.cs
- TableRow.cs
- LayoutDump.cs
- ProgressBarRenderer.cs
- ComponentEditorPage.cs
- SafeEventHandle.cs
- Error.cs
- CuspData.cs
- IProvider.cs
- CopyNodeSetAction.cs
- WebSysDisplayNameAttribute.cs
- ZipIOExtraFieldPaddingElement.cs
- XamlDesignerSerializationManager.cs
- WindowsTitleBar.cs
- ISO2022Encoding.cs
- CultureSpecificStringDictionary.cs
- WMIInterop.cs
- WebPartPersonalization.cs
- PropertyInfoSet.cs
- CommandDesigner.cs
- ImageList.cs
- EnumBuilder.cs
- ObjectDataSourceWizardForm.cs
- StreamInfo.cs
- IntegrationExceptionEventArgs.cs
- SectionInput.cs
- WindowsPrincipal.cs
- SynchronizedInputHelper.cs
- CompoundFileStorageReference.cs
- XmlNamedNodeMap.cs
- SqlExpander.cs
- ConnectionsZoneAutoFormat.cs
- XmlSubtreeReader.cs
- ToolStripDropDownMenu.cs
- ReferenceConverter.cs
- NativeMethods.cs
- Method.cs
- FontResourceCache.cs
- CriticalExceptions.cs
- CompatibleComparer.cs
- RandomNumberGenerator.cs
- RenderingBiasValidation.cs
- BitmapDownload.cs
- CqlWriter.cs
- SettingsAttributes.cs
- TemplateComponentConnector.cs
- RSAOAEPKeyExchangeDeformatter.cs
- SqlDataSourceCache.cs
- Listbox.cs
- WebPartPersonalization.cs
- dsa.cs
- ContractReference.cs
- Model3D.cs
- FontSizeConverter.cs
- BinaryObjectWriter.cs
- TableItemPatternIdentifiers.cs
- OleDbRowUpdatingEvent.cs
- FormatException.cs
- mediaclock.cs
- DesignerActionGlyph.cs
- VirtualPathUtility.cs
- FtpRequestCacheValidator.cs
- DataControlFieldCell.cs
- HtmlInputSubmit.cs
- clipboard.cs
- SamlAssertion.cs
- MailWriter.cs
- Win32.cs
- WebPartEditorOkVerb.cs
- SQLChars.cs
- DelegatingTypeDescriptionProvider.cs
- QuaternionConverter.cs
- Parameter.cs
- DbException.cs
- ModifierKeysConverter.cs
- NavigationEventArgs.cs
- Utils.cs
- Util.cs
- UserNameSecurityTokenProvider.cs
- UrlEncodedParameterWriter.cs
- SerializationSectionGroup.cs
- DesignerLoader.cs
- ServiceInfo.cs
- ToolbarAUtomationPeer.cs
- SqlDataSource.cs
- FeatureManager.cs
- XmlParser.cs
- MasterPageBuildProvider.cs
- SequenceNumber.cs
- ServiceHostingEnvironmentSection.cs
- ProxyManager.cs
- CompModSwitches.cs
- VirtualPathProvider.cs
- Properties.cs
- QueryInterceptorAttribute.cs
- Int16KeyFrameCollection.cs
- Polyline.cs
- HttpDigestClientCredential.cs
- DateTimeValueSerializerContext.cs
- TypeExtensions.cs