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
- ActivityCodeDomSerializer.cs
- HtmlInputPassword.cs
- DataServiceCollectionOfT.cs
- FileDialog.cs
- GridView.cs
- DiscoveryExceptionDictionary.cs
- HostProtectionException.cs
- ViewStateException.cs
- XmlSequenceWriter.cs
- FieldDescriptor.cs
- WebBrowserEvent.cs
- DataGridViewSelectedRowCollection.cs
- Wildcard.cs
- PersonalizationStateInfo.cs
- ProviderMetadataCachedInformation.cs
- GACMembershipCondition.cs
- CheckoutException.cs
- TranslateTransform.cs
- WebPartsPersonalizationAuthorization.cs
- Polyline.cs
- ProfileEventArgs.cs
- CodeVariableReferenceExpression.cs
- ItemContainerGenerator.cs
- DeviceSpecificDialogCachedState.cs
- AbstractSvcMapFileLoader.cs
- CompilationSection.cs
- DataGridViewColumnConverter.cs
- ObjectStateManagerMetadata.cs
- LinqTreeNodeEvaluator.cs
- ValidationManager.cs
- SqlRowUpdatingEvent.cs
- ClockGroup.cs
- DataBoundLiteralControl.cs
- dataSvcMapFileLoader.cs
- SqlMultiplexer.cs
- DataServiceRequestOfT.cs
- cache.cs
- FileReservationCollection.cs
- CompilationRelaxations.cs
- XmlAttributes.cs
- CodeNamespaceImportCollection.cs
- RenderCapability.cs
- Single.cs
- TranslateTransform.cs
- CannotUnloadAppDomainException.cs
- connectionpool.cs
- RTLAwareMessageBox.cs
- GenerateScriptTypeAttribute.cs
- StylusPointPropertyInfoDefaults.cs
- nulltextcontainer.cs
- AnimationLayer.cs
- Style.cs
- NativeMethods.cs
- TypeCollectionDesigner.xaml.cs
- Tag.cs
- XmlAnyAttributeAttribute.cs
- DoubleAnimationUsingPath.cs
- PersistenceTypeAttribute.cs
- UDPClient.cs
- GifBitmapDecoder.cs
- DataGridItemCollection.cs
- SelectionEditingBehavior.cs
- ActivityMarkupSerializer.cs
- CommandHelper.cs
- DataMisalignedException.cs
- CodeIdentifier.cs
- OpenTypeLayoutCache.cs
- ScriptingRoleServiceSection.cs
- ApplicationServicesHostFactory.cs
- Operator.cs
- PropertyGrid.cs
- ProgressBar.cs
- DataGridAutoFormatDialog.cs
- ModelVisual3D.cs
- SafeCertificateContext.cs
- XmlBinaryReader.cs
- Expander.cs
- EntityViewGenerationConstants.cs
- Brush.cs
- EncodingStreamWrapper.cs
- StylusButtonEventArgs.cs
- ApplicationProxyInternal.cs
- UserPersonalizationStateInfo.cs
- SQLInt32.cs
- CodeMemberProperty.cs
- XmlSchemaAnyAttribute.cs
- PaginationProgressEventArgs.cs
- WebServicesSection.cs
- DataPagerFieldItem.cs
- PathFigure.cs
- XPathPatternParser.cs
- ObjectStateFormatter.cs
- IndexExpression.cs
- MessageRpc.cs
- SQLDateTimeStorage.cs
- PeerName.cs
- CodePageEncoding.cs
- SafeViewOfFileHandle.cs
- diagnosticsswitches.cs
- XmlCharType.cs