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
- RuntimeArgumentHandle.cs
- ZoneButton.cs
- Timer.cs
- Int64.cs
- SourceLineInfo.cs
- DataServiceContext.cs
- CommandID.cs
- XmlReturnReader.cs
- WindowsListViewItemStartMenu.cs
- StylusPointDescription.cs
- MetadataFile.cs
- MemoryFailPoint.cs
- AsmxEndpointPickerExtension.cs
- GlobalProxySelection.cs
- Attribute.cs
- WindowAutomationPeer.cs
- ConnectionProviderAttribute.cs
- FileUpload.cs
- XmlAttributeOverrides.cs
- SimpleWebHandlerParser.cs
- ReadOnlyHierarchicalDataSource.cs
- DbCommandDefinition.cs
- ExpandedWrapper.cs
- RuntimeResourceSet.cs
- MemberNameValidator.cs
- Error.cs
- xmlformatgeneratorstatics.cs
- TextInfo.cs
- StringKeyFrameCollection.cs
- SqlCacheDependency.cs
- TextTreeInsertUndoUnit.cs
- figurelengthconverter.cs
- DesignerProperties.cs
- RightsManagementPermission.cs
- GatewayIPAddressInformationCollection.cs
- DisposableCollectionWrapper.cs
- BaseResourcesBuildProvider.cs
- XmlnsDictionary.cs
- PropertyGridView.cs
- HtmlInputHidden.cs
- GeneralTransform.cs
- DataGridViewControlCollection.cs
- _UncName.cs
- QilInvokeLateBound.cs
- RemotingConfigParser.cs
- TreeView.cs
- ColorTransformHelper.cs
- RegexCompiler.cs
- ContextMenuAutomationPeer.cs
- SiteOfOriginContainer.cs
- CoTaskMemUnicodeSafeHandle.cs
- HandlerBase.cs
- DescendantQuery.cs
- PropagatorResult.cs
- Helper.cs
- EntityDesignerDataSourceView.cs
- ButtonBaseAutomationPeer.cs
- WinFormsSpinner.cs
- QilLoop.cs
- ClientTargetSection.cs
- MetadataHelper.cs
- XmlSerializationReader.cs
- RTLAwareMessageBox.cs
- OpCodes.cs
- CodeDOMUtility.cs
- RegexCode.cs
- MetadataConversionError.cs
- BaseUriHelper.cs
- initElementDictionary.cs
- XhtmlBasicCommandAdapter.cs
- PointLight.cs
- ConvertTextFrag.cs
- Collection.cs
- CodeMemberMethod.cs
- WebPartDisplayMode.cs
- Filter.cs
- DoubleMinMaxAggregationOperator.cs
- VectorKeyFrameCollection.cs
- ExceptionUtil.cs
- XamlSerializerUtil.cs
- XmlAttributeAttribute.cs
- InvariantComparer.cs
- DbConnectionPoolGroup.cs
- TraversalRequest.cs
- StringBuilder.cs
- BasicViewGenerator.cs
- CodeVariableDeclarationStatement.cs
- RestHandler.cs
- CapabilitiesRule.cs
- SQLMoneyStorage.cs
- OleDbDataReader.cs
- PackageRelationshipCollection.cs
- GlobalProxySelection.cs
- QilDataSource.cs
- DataTable.cs
- CryptoProvider.cs
- Stroke.cs
- TemplateAction.cs
- ContextMenuStrip.cs
- ToolStripDropDownItem.cs