Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / Objects / ELinq / Visitors / LinqTreeNodeEvaluator.cs / 1 / LinqTreeNodeEvaluator.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System.Linq.Expressions; using System.Collections.Generic; namespace System.Data.Objects.ELinq { ////// Goes from the bottom to top and nominates nodes where all the nodes /// below the node return true from the shouldBeNominatedDelegate /// internal sealed class LinqTreeNodeEvaluator : ExpressionVisitor { HashSet_nodesToEvaluate; private LinqTreeNodeEvaluator(HashSet nodesToEvaluate) { _nodesToEvaluate = nodesToEvaluate; } internal static Expression EvaluateClosuresAndClientEvalNodes(Expression expression) { return Evaluate(expression, LinqMaximalSubtreeNominator.Nominate( expression, new HashSet (), e => ExpressionEvaluator.IsExpressionNodeAClosure(e) || ExpressionEvaluator.IsExpressionNodeClientEvaluatable(e) ) ); } internal static Expression Evaluate(Expression expression, HashSet nodesToEvaluate) { if (nodesToEvaluate.Count == 0) { // I can save you some time on this one... return expression; } LinqTreeNodeEvaluator nominator = new LinqTreeNodeEvaluator(nodesToEvaluate); return nominator.Visit(expression); } internal override Expression Visit(Expression exp) { if (exp != null && exp.NodeType != ExpressionType.Constant && _nodesToEvaluate.Contains(exp)) { return Expression.Constant(ExpressionEvaluator.EvaluateExpression(exp), exp.Type); } return base.Visit(exp); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System.Linq.Expressions; using System.Collections.Generic; namespace System.Data.Objects.ELinq { ////// Goes from the bottom to top and nominates nodes where all the nodes /// below the node return true from the shouldBeNominatedDelegate /// internal sealed class LinqTreeNodeEvaluator : ExpressionVisitor { HashSet_nodesToEvaluate; private LinqTreeNodeEvaluator(HashSet nodesToEvaluate) { _nodesToEvaluate = nodesToEvaluate; } internal static Expression EvaluateClosuresAndClientEvalNodes(Expression expression) { return Evaluate(expression, LinqMaximalSubtreeNominator.Nominate( expression, new HashSet (), e => ExpressionEvaluator.IsExpressionNodeAClosure(e) || ExpressionEvaluator.IsExpressionNodeClientEvaluatable(e) ) ); } internal static Expression Evaluate(Expression expression, HashSet nodesToEvaluate) { if (nodesToEvaluate.Count == 0) { // I can save you some time on this one... return expression; } LinqTreeNodeEvaluator nominator = new LinqTreeNodeEvaluator(nodesToEvaluate); return nominator.Visit(expression); } internal override Expression Visit(Expression exp) { if (exp != null && exp.NodeType != ExpressionType.Constant && _nodesToEvaluate.Contains(exp)) { return Expression.Constant(ExpressionEvaluator.EvaluateExpression(exp), exp.Type); } return base.Visit(exp); } } } // 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
- LingerOption.cs
- SymmetricKeyWrap.cs
- SingleConverter.cs
- ProgressBar.cs
- Stylus.cs
- BinaryOperationBinder.cs
- DbConnectionPoolGroup.cs
- XmlSerializerFaultFormatter.cs
- CodeGroup.cs
- ModuleConfigurationInfo.cs
- OleDbPermission.cs
- OverrideMode.cs
- ArraySegment.cs
- RegexReplacement.cs
- _AutoWebProxyScriptEngine.cs
- __ComObject.cs
- CompilationUtil.cs
- AvtEvent.cs
- ListDictionaryInternal.cs
- InstanceLockedException.cs
- XmlIlGenerator.cs
- ConditionalWeakTable.cs
- PointHitTestResult.cs
- AttachedAnnotation.cs
- LayoutInformation.cs
- SemanticResolver.cs
- JournalEntryStack.cs
- XhtmlBasicImageAdapter.cs
- TextFormatterContext.cs
- RectAnimationUsingKeyFrames.cs
- WebPartMovingEventArgs.cs
- AnnotationResourceChangedEventArgs.cs
- ArrangedElement.cs
- DeferrableContent.cs
- PathFigure.cs
- OverlappedContext.cs
- TypeDescriptionProviderAttribute.cs
- ReadOnlyDataSource.cs
- AssociationSetMetadata.cs
- ListMarkerSourceInfo.cs
- FileStream.cs
- BuildTopDownAttribute.cs
- SoapFault.cs
- DBSchemaTable.cs
- BitmapEffectGroup.cs
- XmlSchemaFacet.cs
- ConvertersCollection.cs
- BuilderPropertyEntry.cs
- ExecutedRoutedEventArgs.cs
- BamlLocalizableResource.cs
- EndOfStreamException.cs
- FrameworkObject.cs
- ColumnResult.cs
- SafeHandles.cs
- XsdBuilder.cs
- QilReference.cs
- NetworkCredential.cs
- ServiceNotStartedException.cs
- DataControlPagerLinkButton.cs
- Invariant.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- AnnotationAuthorChangedEventArgs.cs
- SpotLight.cs
- MarkupExtensionSerializer.cs
- WebPart.cs
- PreDigestedSignedInfo.cs
- HandlerFactoryWrapper.cs
- CaseInsensitiveHashCodeProvider.cs
- FontUnitConverter.cs
- DesignerDataTableBase.cs
- TemplatePropertyEntry.cs
- HttpFileCollection.cs
- CollectionChangedEventManager.cs
- RenderTargetBitmap.cs
- UidPropertyAttribute.cs
- IPipelineRuntime.cs
- WorkflowInvoker.cs
- NestedContainer.cs
- ExpressionConverter.cs
- TreeWalkHelper.cs
- SAPIEngineTypes.cs
- EncodingInfo.cs
- IdnMapping.cs
- XmlSchemaAnyAttribute.cs
- SystemTcpConnection.cs
- ColumnResult.cs
- KerberosSecurityTokenAuthenticator.cs
- SQLBytes.cs
- ErrorWrapper.cs
- AppDomainShutdownMonitor.cs
- SystemUnicastIPAddressInformation.cs
- AttachedAnnotation.cs
- UriTemplateTrieNode.cs
- WarningException.cs
- SlipBehavior.cs
- PerformanceCounterPermission.cs
- XPathDescendantIterator.cs
- SessionStateItemCollection.cs
- ADMembershipProvider.cs
- BulletedListEventArgs.cs