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
- PostBackOptions.cs
- Merger.cs
- nulltextnavigator.cs
- XmlAutoDetectWriter.cs
- CharacterMetrics.cs
- RawMouseInputReport.cs
- SqlProcedureAttribute.cs
- SecurityManager.cs
- DataGridCommandEventArgs.cs
- TraceData.cs
- FontCacheLogic.cs
- EncoderParameter.cs
- PackWebRequest.cs
- GrammarBuilderWildcard.cs
- PagesChangedEventArgs.cs
- ImageInfo.cs
- FormViewPageEventArgs.cs
- TextRangeProviderWrapper.cs
- SecureStringHasher.cs
- ScrollChrome.cs
- WSSecurityOneDotOneReceiveSecurityHeader.cs
- ArithmeticException.cs
- CheckableControlBaseAdapter.cs
- Point4DValueSerializer.cs
- MetadataFile.cs
- Compiler.cs
- DocumentSchemaValidator.cs
- BindingCompleteEventArgs.cs
- LinqDataSourceSelectEventArgs.cs
- DocumentPageView.cs
- CmsInterop.cs
- ObsoleteAttribute.cs
- DBSqlParser.cs
- COM2TypeInfoProcessor.cs
- Win32MouseDevice.cs
- DataError.cs
- SqlXml.cs
- ADRoleFactory.cs
- CompositeClientFormatter.cs
- DataGridPreparingCellForEditEventArgs.cs
- DecoderReplacementFallback.cs
- StaticContext.cs
- WebBrowser.cs
- SoapObjectReader.cs
- RemoteHelper.cs
- EntityViewGenerator.cs
- ScriptRegistrationManager.cs
- Thickness.cs
- TileBrush.cs
- ImageKeyConverter.cs
- Module.cs
- ProgressiveCrcCalculatingStream.cs
- FormsAuthenticationModule.cs
- Package.cs
- DesignerLinkAdapter.cs
- ValidatorUtils.cs
- KeyGestureValueSerializer.cs
- DbMetaDataCollectionNames.cs
- DataKeyCollection.cs
- _FixedSizeReader.cs
- DefaultValueConverter.cs
- NodeFunctions.cs
- EventData.cs
- SafeArrayTypeMismatchException.cs
- HttpCachePolicyWrapper.cs
- DetailsViewDeletedEventArgs.cs
- SafeFileHandle.cs
- HttpHandler.cs
- TripleDES.cs
- future.cs
- FloaterBaseParagraph.cs
- ExportOptions.cs
- DelegatedStream.cs
- ToolStripPanelRow.cs
- TableLayoutPanel.cs
- UnmanagedMemoryStream.cs
- SqlBuffer.cs
- RtfControlWordInfo.cs
- PageAsyncTask.cs
- CqlLexerHelpers.cs
- SevenBitStream.cs
- ErrorEventArgs.cs
- DataChangedEventManager.cs
- SqlDataSourceView.cs
- DataFormats.cs
- WebPartVerb.cs
- UnhandledExceptionEventArgs.cs
- Highlights.cs
- SslStreamSecurityBindingElement.cs
- WebServiceEnumData.cs
- RedBlackList.cs
- ThicknessAnimation.cs
- DispatchChannelSink.cs
- HttpHandlerAction.cs
- GlobalId.cs
- OracleConnectionFactory.cs
- StatusBar.cs
- SrgsOneOf.cs
- SettingsPropertyNotFoundException.cs
- _NestedSingleAsyncResult.cs