Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / Microsoft / VisualBasic / Activities / VisualBasicReference.cs / 1305376 / VisualBasicReference.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace Microsoft.VisualBasic.Activities
{
using System;
using System.Activities;
using System.Activities.ExpressionParser;
using System.Activities.XamlIntegration;
using System.Linq.Expressions;
using System.Windows.Markup;
public sealed class VisualBasicReference : CodeActivity>, IValueSerializableExpression, IExpressionContainer, IVisualBasicExpression
{
Expression> expressionTree;
LocationFactory locationFactory;
public VisualBasicReference()
: base()
{
this.SkipArgumentResolution = true;
}
public VisualBasicReference(string expressionText)
: this()
{
this.ExpressionText = expressionText;
}
public string ExpressionText
{
get;
set;
}
Expression IExpressionContainer.Expression
{
get { return this.expressionTree; }
}
protected override Location Execute(CodeActivityContext context)
{
if (this.expressionTree != null)
{
return GetValueCore(context);
}
else
{
return null;
}
}
internal override bool TryGetValue(ActivityContext context, out Location value)
{
if (!this.SkipArgumentResolution && this.RuntimeArguments.Count > 1)
{
// We can't fast path because we have arguments other than the result
// and we haven't obtained inlined references
value = null;
return false;
}
value = GetValueCore(context);
return true;
}
Location GetValueCore(ActivityContext context)
{
if (this.locationFactory == null)
{
this.locationFactory = ExpressionUtilities.CreateLocationFactory(this.expressionTree);
}
return this.locationFactory.CreateLocation(context);
}
protected override void CacheMetadata(CodeActivityMetadata metadata)
{
this.expressionTree = null;
try
{
this.expressionTree = VisualBasicHelper.Compile(this.ExpressionText, metadata);
// inspect the expressionTree to see if it is a valid location expression(L-value)
string extraErrorMessage = null;
if (!metadata.HasViolations && (this.expressionTree == null || !ExpressionUtilities.IsLocation(this.expressionTree, typeof(TResult), out extraErrorMessage)))
{
string errorMessage = SR.InvalidLValueExpression;
if (extraErrorMessage != null)
{
errorMessage += ":" + extraErrorMessage;
}
this.expressionTree = null;
metadata.AddValidationError(SR.CompilerErrorSpecificExpression(this.ExpressionText, errorMessage));
}
}
catch (SourceExpressionException e)
{
metadata.AddValidationError(e.Message);
}
}
public bool CanConvertToString(IValueSerializerContext context)
{
// we can always convert to a string
return true;
}
public string ConvertToString(IValueSerializerContext context)
{
// Return our bracket-escaped text
return "[" + this.ExpressionText + "]";
}
}
}
// 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
- RowToParametersTransformer.cs
- BufferAllocator.cs
- SplitterEvent.cs
- MTConfigUtil.cs
- IndentTextWriter.cs
- _SSPIWrapper.cs
- BindingList.cs
- DispatchChannelSink.cs
- Int32Converter.cs
- StrongNameUtility.cs
- ColorConvertedBitmap.cs
- Label.cs
- WebPartAddingEventArgs.cs
- ProxyHwnd.cs
- AnnotationMap.cs
- TypeProvider.cs
- HttpRequestCacheValidator.cs
- DetailsViewCommandEventArgs.cs
- ElementNotAvailableException.cs
- ProfileParameter.cs
- VectorAnimationBase.cs
- HttpCacheParams.cs
- LocatorManager.cs
- cookiecontainer.cs
- ExchangeUtilities.cs
- HwndMouseInputProvider.cs
- ListViewDeleteEventArgs.cs
- CapacityStreamGeometryContext.cs
- CompoundFileStorageReference.cs
- ThreadStateException.cs
- BitmapFrame.cs
- FunctionQuery.cs
- HtmlToClrEventProxy.cs
- SplitContainer.cs
- HeaderPanel.cs
- MetroSerializationManager.cs
- GridEntry.cs
- _CookieModule.cs
- TypeDelegator.cs
- SimpleWorkerRequest.cs
- DateTimeConverter.cs
- MeshGeometry3D.cs
- BitmapEffectDrawing.cs
- TableLayoutColumnStyleCollection.cs
- AlternateViewCollection.cs
- LingerOption.cs
- CommandTreeTypeHelper.cs
- DataGridHeaderBorder.cs
- FacetValues.cs
- StyleSelector.cs
- DataBinding.cs
- LocalizableAttribute.cs
- PropertyTabChangedEvent.cs
- SplineKeyFrames.cs
- Normalization.cs
- LassoHelper.cs
- MailAddress.cs
- ConfigXmlElement.cs
- CDSsyncETWBCLProvider.cs
- ControlType.cs
- NestedContainer.cs
- tibetanshape.cs
- SoapFaultCodes.cs
- KeyEvent.cs
- TextRunCache.cs
- SmiEventSink_Default.cs
- XmlCountingReader.cs
- DropShadowBitmapEffect.cs
- TranslateTransform3D.cs
- CursorConverter.cs
- ThreadStaticAttribute.cs
- TemplateColumn.cs
- MessageHeaderInfoTraceRecord.cs
- UICuesEvent.cs
- IRCollection.cs
- ListItemParagraph.cs
- ScrollBarAutomationPeer.cs
- RuleProcessor.cs
- IDReferencePropertyAttribute.cs
- RoleManagerEventArgs.cs
- DataGridViewColumnConverter.cs
- ColumnMapTranslator.cs
- DrawingContextWalker.cs
- DataRecord.cs
- RuntimeConfigLKG.cs
- assemblycache.cs
- CodeDomConfigurationHandler.cs
- COMException.cs
- CustomValidator.cs
- GridViewDeletedEventArgs.cs
- VectorCollectionConverter.cs
- RelationshipEntry.cs
- DataFormat.cs
- Win32PrintDialog.cs
- PropertyMapper.cs
- CatalogZone.cs
- RuntimeArgumentHandle.cs
- Calendar.cs
- SessionState.cs
- RequestTimeoutManager.cs