Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / ALinq / ParameterReplacerVisitor.cs / 1 / ParameterReplacerVisitor.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides an expression visitor that can replace a ParameterExpression.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Client
{
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Diagnostics;
/// Provides an expression visitor that can replace a .
internal class ParameterReplacerVisitor : ExpressionVisitor
{
/// Expression to replace with.
private Expression newExpression;
/// Parameter to replace.
private ParameterExpression oldParameter;
/// Initializes a new instance.
/// Parameter to replace.
/// Expression to replace with.
private ParameterReplacerVisitor(ParameterExpression oldParameter, Expression newExpression)
{
this.oldParameter = oldParameter;
this.newExpression = newExpression;
}
///
/// Replaces the occurences of for in
/// .
///
/// Expression to perform replacement on.
/// Parameter to replace.
/// Expression to replace with.
/// A new expression with the replacement performed.
internal static Expression Replace(Expression expression, ParameterExpression oldParameter, Expression newExpression)
{
Debug.Assert(expression != null, "expression != null");
Debug.Assert(oldParameter != null, "oldParameter != null");
Debug.Assert(newExpression != null, "newExpression != null");
return new ParameterReplacerVisitor(oldParameter, newExpression).Visit(expression);
}
/// ParameterExpression visit method.
/// The ParameterExpression expression to visit
/// The visited ParameterExpression expression
internal override Expression VisitParameter(ParameterExpression p)
{
if (p == this.oldParameter)
{
return this.newExpression;
}
else
{
return p;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides an expression visitor that can replace a ParameterExpression.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Client
{
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Diagnostics;
/// Provides an expression visitor that can replace a .
internal class ParameterReplacerVisitor : ExpressionVisitor
{
/// Expression to replace with.
private Expression newExpression;
/// Parameter to replace.
private ParameterExpression oldParameter;
/// Initializes a new instance.
/// Parameter to replace.
/// Expression to replace with.
private ParameterReplacerVisitor(ParameterExpression oldParameter, Expression newExpression)
{
this.oldParameter = oldParameter;
this.newExpression = newExpression;
}
///
/// Replaces the occurences of for in
/// .
///
/// Expression to perform replacement on.
/// Parameter to replace.
/// Expression to replace with.
/// A new expression with the replacement performed.
internal static Expression Replace(Expression expression, ParameterExpression oldParameter, Expression newExpression)
{
Debug.Assert(expression != null, "expression != null");
Debug.Assert(oldParameter != null, "oldParameter != null");
Debug.Assert(newExpression != null, "newExpression != null");
return new ParameterReplacerVisitor(oldParameter, newExpression).Visit(expression);
}
/// ParameterExpression visit method.
/// The ParameterExpression expression to visit
/// The visited ParameterExpression expression
internal override Expression VisitParameter(ParameterExpression p)
{
if (p == this.oldParameter)
{
return this.newExpression;
}
else
{
return p;
}
}
}
}
// 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
- PagesChangedEventArgs.cs
- ControlCodeDomSerializer.cs
- DoubleStorage.cs
- MustUnderstandBehavior.cs
- ProviderException.cs
- LocalizableAttribute.cs
- NamespaceDecl.cs
- tibetanshape.cs
- WebBrowserSiteBase.cs
- OleDbMetaDataFactory.cs
- DataGridColumnCollection.cs
- ObjRef.cs
- AuthenticateEventArgs.cs
- ObjectDataSourceStatusEventArgs.cs
- SafeNativeMethods.cs
- connectionpool.cs
- StorageMappingItemLoader.cs
- TimeSpanStorage.cs
- WebReferencesBuildProvider.cs
- XMLSchema.cs
- MetadataArtifactLoaderCompositeResource.cs
- StrongNameMembershipCondition.cs
- SchemaTypeEmitter.cs
- RectangleConverter.cs
- Sequence.cs
- QuaternionValueSerializer.cs
- keycontainerpermission.cs
- Object.cs
- X509AudioLogo.cs
- SourceLineInfo.cs
- EntityDataSourceReferenceGroup.cs
- HttpHandlerAction.cs
- DbProviderManifest.cs
- NavigatorInput.cs
- Parsers.cs
- TrackingProfileDeserializationException.cs
- PointIndependentAnimationStorage.cs
- GeneratedCodeAttribute.cs
- ImageDrawing.cs
- Exceptions.cs
- ServiceSettingsResponseInfo.cs
- FixedSOMSemanticBox.cs
- ReaderWriterLock.cs
- AppDomainUnloadedException.cs
- IPPacketInformation.cs
- PerformanceCounterPermissionEntryCollection.cs
- Baml2006ReaderFrame.cs
- _BasicClient.cs
- DoubleKeyFrameCollection.cs
- StreamedWorkflowDefinitionContext.cs
- Profiler.cs
- AutoGeneratedFieldProperties.cs
- ThaiBuddhistCalendar.cs
- DataColumnMappingCollection.cs
- UIElement3D.cs
- InputDevice.cs
- CLSCompliantAttribute.cs
- BamlMapTable.cs
- FormsAuthenticationUser.cs
- DataMemberAttribute.cs
- PriorityBinding.cs
- SecurityContext.cs
- TablePatternIdentifiers.cs
- AutoGeneratedField.cs
- CommonDialog.cs
- FileDetails.cs
- DiagnosticTraceSource.cs
- PageVisual.cs
- DataControlFieldHeaderCell.cs
- RowToParametersTransformer.cs
- MemberInfoSerializationHolder.cs
- LinqDataSource.cs
- BehaviorDragDropEventArgs.cs
- SmtpCommands.cs
- IsolatedStorageFilePermission.cs
- MessageSecurityOverMsmqElement.cs
- AppDomainManager.cs
- PageParser.cs
- OdbcStatementHandle.cs
- CellPartitioner.cs
- MimeBasePart.cs
- _NegotiateClient.cs
- FrameworkTextComposition.cs
- RichTextBox.cs
- DataKeyPropertyAttribute.cs
- CodeBinaryOperatorExpression.cs
- XAMLParseException.cs
- PropertyGroupDescription.cs
- NameNode.cs
- columnmapfactory.cs
- ToolBar.cs
- SQLMoneyStorage.cs
- RC2.cs
- XmlSchemaCompilationSettings.cs
- smtppermission.cs
- MergeEnumerator.cs
- NamedPipeActivation.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- AudioSignalProblemOccurredEventArgs.cs
- XmlDesigner.cs