Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / ALinq / ParameterReplacerVisitor.cs / 1305376 / 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.Diagnostics;
using System.Linq.Expressions;
/// Provides an expression visitor that can replace a .
internal class ParameterReplacerVisitor : ALinqExpressionVisitor
{
/// 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.Diagnostics;
using System.Linq.Expressions;
/// Provides an expression visitor that can replace a .
internal class ParameterReplacerVisitor : ALinqExpressionVisitor
{
/// 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
- EventHandlerList.cs
- printdlgexmarshaler.cs
- XmlHelper.cs
- ApplicationFileParser.cs
- ParagraphVisual.cs
- DesignerView.xaml.cs
- CodeTypeDeclaration.cs
- SequenceDesigner.cs
- Storyboard.cs
- Connector.cs
- DoubleIndependentAnimationStorage.cs
- WindowsGraphicsCacheManager.cs
- ReferencedAssembly.cs
- DataGridPageChangedEventArgs.cs
- ContainerActivationHelper.cs
- ServiceAuthorizationElement.cs
- AdobeCFFWrapper.cs
- HttpCacheVaryByContentEncodings.cs
- HandleCollector.cs
- FileDialogCustomPlace.cs
- PersonalizableTypeEntry.cs
- UnsettableComboBox.cs
- EndEvent.cs
- ConfigurationStrings.cs
- TextRange.cs
- ExpressionBindingCollection.cs
- QueryException.cs
- CheckPair.cs
- Point.cs
- SR.cs
- NavigationPropertyEmitter.cs
- MetadataHelper.cs
- DesignBinding.cs
- PhoneCall.cs
- Converter.cs
- HttpCookieCollection.cs
- Variant.cs
- RbTree.cs
- SqlReorderer.cs
- CustomValidator.cs
- OutputWindow.cs
- EdmComplexTypeAttribute.cs
- CurrentChangedEventManager.cs
- PresentationSource.cs
- StringStorage.cs
- TagNameToTypeMapper.cs
- ScriptResourceMapping.cs
- DataBoundControlAdapter.cs
- WebAdminConfigurationHelper.cs
- BrowserCapabilitiesFactory35.cs
- ClientTargetSection.cs
- WorkflowTransactionOptions.cs
- UnsafeNetInfoNativeMethods.cs
- TextRangeProviderWrapper.cs
- CorrelationService.cs
- ResourceContainer.cs
- XmlSchemaAttribute.cs
- HtmlInputFile.cs
- HttpClientChannel.cs
- ExtractCollection.cs
- InputChannelAcceptor.cs
- ProviderConnectionPointCollection.cs
- OdbcDataAdapter.cs
- TabletDeviceInfo.cs
- MultilineStringConverter.cs
- __TransparentProxy.cs
- EnumValAlphaComparer.cs
- MemberPath.cs
- AnnotationService.cs
- ReadOnlyHierarchicalDataSourceView.cs
- AmbientValueAttribute.cs
- KoreanCalendar.cs
- ValueQuery.cs
- SelectionEditor.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- RSAPKCS1SignatureDeformatter.cs
- CodeArrayCreateExpression.cs
- ReferenceConverter.cs
- ConsumerConnectionPoint.cs
- ApplicationTrust.cs
- SystemNetworkInterface.cs
- AmbiguousMatchException.cs
- DbParameterCollectionHelper.cs
- WpfXamlLoader.cs
- Random.cs
- Fault.cs
- XmlDataCollection.cs
- Focus.cs
- FileIOPermission.cs
- _Win32.cs
- PeerValidationBehavior.cs
- HttpCacheParams.cs
- SqlBulkCopy.cs
- DataGridCommandEventArgs.cs
- XmlSchemaAnnotation.cs
- DataGridViewMethods.cs
- X509Certificate.cs
- RawStylusSystemGestureInputReport.cs
- LayoutManager.cs
- ViewDesigner.cs