Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- PersonalizationProviderHelper.cs
- TypeSystem.cs
- RadioButtonFlatAdapter.cs
- SystemIPAddressInformation.cs
- ConfigurationStrings.cs
- CharEnumerator.cs
- DataGridRow.cs
- XmlSchemaSimpleTypeUnion.cs
- ColumnCollection.cs
- GridViewDeletedEventArgs.cs
- ImmutableObjectAttribute.cs
- InspectionWorker.cs
- Module.cs
- IIS7ConfigurationLoader.cs
- Component.cs
- GridViewEditEventArgs.cs
- SmtpException.cs
- OwnerDrawPropertyBag.cs
- ContainerParagraph.cs
- EventMappingSettingsCollection.cs
- Scalars.cs
- DispatcherTimer.cs
- MetadataArtifactLoaderCompositeResource.cs
- DataKeyArray.cs
- brushes.cs
- StructuredTypeEmitter.cs
- AssemblyUtil.cs
- SqlBooleanizer.cs
- RegisteredArrayDeclaration.cs
- KeyEvent.cs
- RawStylusInputCustomData.cs
- DrawingVisual.cs
- _HelperAsyncResults.cs
- DataGridViewCell.cs
- FrameworkObject.cs
- NameValueFileSectionHandler.cs
- CodeMethodInvokeExpression.cs
- DoubleCollectionValueSerializer.cs
- EnumerationRangeValidationUtil.cs
- MsmqElementBase.cs
- SqlExpressionNullability.cs
- SQLDateTime.cs
- WinEventQueueItem.cs
- TableLayoutPanel.cs
- HandlerBase.cs
- WeakReferenceEnumerator.cs
- CacheAxisQuery.cs
- ListItem.cs
- ErrorFormatter.cs
- ArcSegment.cs
- PageAsyncTask.cs
- AddressHeader.cs
- MexHttpBindingCollectionElement.cs
- Method.cs
- ImageKeyConverter.cs
- MetadataArtifactLoaderCompositeFile.cs
- ExtentCqlBlock.cs
- TableLayoutPanelCellPosition.cs
- DES.cs
- PrintSchema.cs
- HttpValueCollection.cs
- ToolStripGrip.cs
- AnnotationHelper.cs
- COM2TypeInfoProcessor.cs
- AppSecurityManager.cs
- TreeNodeCollectionEditorDialog.cs
- PenThreadWorker.cs
- DocumentViewerConstants.cs
- ColumnResult.cs
- ListSortDescription.cs
- StructureChangedEventArgs.cs
- SerializationInfo.cs
- BooleanProjectedSlot.cs
- FontResourceCache.cs
- DoubleStorage.cs
- WebPartMenuStyle.cs
- PropagatorResult.cs
- ObjectTokenCategory.cs
- UnsafeNativeMethods.cs
- TraceData.cs
- BitmapEffectOutputConnector.cs
- SystemIcons.cs
- OdbcEnvironment.cs
- XhtmlBasicLiteralTextAdapter.cs
- BoolExpressionVisitors.cs
- ServicesUtilities.cs
- WebUtil.cs
- SQLResource.cs
- SmiEventStream.cs
- WebPartRestoreVerb.cs
- printdlgexmarshaler.cs
- FileSystemEventArgs.cs
- ValidatorAttribute.cs
- StreamGeometryContext.cs
- GridViewPageEventArgs.cs
- InternalBufferOverflowException.cs
- FormConverter.cs
- Screen.cs
- SystemIcons.cs
- lengthconverter.cs