Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- DataGridBeginningEditEventArgs.cs
- IODescriptionAttribute.cs
- EngineSite.cs
- ScriptRef.cs
- Activation.cs
- Line.cs
- AmbientValueAttribute.cs
- BamlResourceDeserializer.cs
- RootContext.cs
- XmlObjectSerializerContext.cs
- GenerateScriptTypeAttribute.cs
- SortKey.cs
- ComEventsSink.cs
- ProjectionQueryOptionExpression.cs
- InternalPermissions.cs
- ModelTreeEnumerator.cs
- HtmlWindow.cs
- SubstitutionList.cs
- TextEditorContextMenu.cs
- TypedReference.cs
- XmlSchemaSimpleContentExtension.cs
- CodeIterationStatement.cs
- DynamicRenderer.cs
- SortQuery.cs
- ItemsChangedEventArgs.cs
- AppDomainProtocolHandler.cs
- ProfileInfo.cs
- SamlAudienceRestrictionCondition.cs
- XmlImplementation.cs
- DataControlLinkButton.cs
- ObjectContext.cs
- CLSCompliantAttribute.cs
- PerformanceCounterLib.cs
- UserPreferenceChangedEventArgs.cs
- Model3DGroup.cs
- Trace.cs
- NotificationContext.cs
- MouseGesture.cs
- Baml2006KeyRecord.cs
- SafeCoTaskMem.cs
- ToolStripComboBox.cs
- DeploymentSection.cs
- CaseExpr.cs
- XamlSerializerUtil.cs
- AttachInfo.cs
- CroppedBitmap.cs
- ReceiveActivityDesignerTheme.cs
- SignatureToken.cs
- StickyNote.cs
- GridViewCancelEditEventArgs.cs
- SerializationSectionGroup.cs
- ResourceManager.cs
- ReturnValue.cs
- recordstatescratchpad.cs
- RunInstallerAttribute.cs
- RequestCachePolicy.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- XPathNode.cs
- ValueOfAction.cs
- HostingEnvironmentWrapper.cs
- securitycriticaldataClass.cs
- Matrix3DStack.cs
- CqlWriter.cs
- Geometry3D.cs
- SmtpDigestAuthenticationModule.cs
- MatrixValueSerializer.cs
- DataGridAddNewRow.cs
- InkCanvasInnerCanvas.cs
- ProfileInfo.cs
- Resources.Designer.cs
- XmlSortKeyAccumulator.cs
- NaturalLanguageHyphenator.cs
- Cursors.cs
- PageTheme.cs
- DataGridViewCheckBoxColumn.cs
- XmlFormatWriterGenerator.cs
- Compiler.cs
- CryptoHandle.cs
- XmlSchemaValidationException.cs
- ConnectionStringsExpressionBuilder.cs
- WizardPanel.cs
- WindowInteropHelper.cs
- HuffmanTree.cs
- Compensation.cs
- IImplicitResourceProvider.cs
- SelectionUIHandler.cs
- CompositeCollection.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- MaskedTextBox.cs
- MimeReflector.cs
- WindowsTab.cs
- SecurityIdentifierElement.cs
- PersistenceContext.cs
- UrlAuthorizationModule.cs
- PreDigestedSignedInfo.cs
- ProfileSettings.cs
- FontDialog.cs
- _IPv6Address.cs
- NamespaceImport.cs
- Style.cs