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
- DocumentViewer.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- ColorBlend.cs
- DataListDesigner.cs
- ZipIOCentralDirectoryBlock.cs
- DataSourceControlBuilder.cs
- VisualStates.cs
- SafeUserTokenHandle.cs
- SimpleMailWebEventProvider.cs
- ToolTipService.cs
- SecureStringHasher.cs
- AlphaSortedEnumConverter.cs
- ProfileSettingsCollection.cs
- Rect3D.cs
- DataObjectEventArgs.cs
- _AutoWebProxyScriptHelper.cs
- DataSourceView.cs
- FormatterConverter.cs
- RemoteWebConfigurationHost.cs
- NameSpaceExtractor.cs
- CodeParameterDeclarationExpressionCollection.cs
- Duration.cs
- DoWorkEventArgs.cs
- DbMetaDataFactory.cs
- GetIndexBinder.cs
- VisualStyleElement.cs
- CompareInfo.cs
- MultiBinding.cs
- CompareValidator.cs
- TabRenderer.cs
- PageContentCollection.cs
- StatusBarDrawItemEvent.cs
- ImageListUtils.cs
- Input.cs
- PackageRelationshipCollection.cs
- DesigntimeLicenseContext.cs
- input.cs
- XmlSchemaNotation.cs
- Crc32.cs
- MessageDescription.cs
- TemplatedMailWebEventProvider.cs
- Int32RectConverter.cs
- DataServiceProviderWrapper.cs
- ConnectionPointCookie.cs
- ConfigXmlCDataSection.cs
- DataColumnMapping.cs
- DirectionalLight.cs
- HasCopySemanticsAttribute.cs
- ConfigurationErrorsException.cs
- TextServicesHost.cs
- DatatypeImplementation.cs
- GridViewUpdateEventArgs.cs
- HtmlElement.cs
- WaitHandleCannotBeOpenedException.cs
- InputBuffer.cs
- ServiceDurableInstance.cs
- CollectionConverter.cs
- ProcessModelSection.cs
- SubclassTypeValidatorAttribute.cs
- XmlSiteMapProvider.cs
- EncodingDataItem.cs
- TransformationRules.cs
- ExpressionBuilderCollection.cs
- ConnectionPointConverter.cs
- DashStyle.cs
- SqlDataSource.cs
- EdgeModeValidation.cs
- Exceptions.cs
- CommonServiceBehaviorElement.cs
- TimeSpanConverter.cs
- FilterException.cs
- PasswordTextNavigator.cs
- SoapHeaderException.cs
- SystemIcmpV6Statistics.cs
- DesignerSerializerAttribute.cs
- QilDataSource.cs
- FlowDocumentPage.cs
- RSAPKCS1KeyExchangeFormatter.cs
- GetCardDetailsRequest.cs
- DetailsViewRow.cs
- DelayLoadType.cs
- WebRequestModulesSection.cs
- DataSetViewSchema.cs
- XMLSyntaxException.cs
- TreeNodeBinding.cs
- NamespaceTable.cs
- DocumentApplicationJournalEntry.cs
- PasswordRecovery.cs
- WindowsMenu.cs
- ProxyHelper.cs
- Win32NamedPipes.cs
- ISO2022Encoding.cs
- StylusShape.cs
- DataControlField.cs
- X509Chain.cs
- CachedPathData.cs
- QilList.cs
- Metafile.cs
- ProfileBuildProvider.cs
- CriticalFinalizerObject.cs