Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / Microsoft / VisualBasic / Activities / VisualBasicValue.cs / 1305376 / VisualBasicValue.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 VisualBasicValue : CodeActivity, IValueSerializableExpression, IExpressionContainer, IVisualBasicExpression
{
Expression> expressionTree;
Func compiledExpression;
public VisualBasicValue()
: base()
{
this.SkipArgumentResolution = true;
}
public VisualBasicValue(string expressionText)
: this()
{
this.ExpressionText = expressionText;
}
public string ExpressionText
{
get;
set;
}
Expression IExpressionContainer.Expression
{
get { return this.expressionTree; }
}
protected override TResult Execute(CodeActivityContext context)
{
if (this.expressionTree != null)
{
return GetValueCore(context);
}
else
{
return default(TResult);
}
}
internal override bool TryGetValue(ActivityContext context, out TResult 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 = default(TResult);
return false;
}
value = GetValueCore(context);
return true;
}
TResult GetValueCore(ActivityContext context)
{
if (this.compiledExpression == null)
{
if (this.expressionTree == null)
{
return default(TResult);
}
this.compiledExpression = this.expressionTree.Compile();
}
return this.compiledExpression(context);
}
protected override void CacheMetadata(CodeActivityMetadata metadata)
{
this.expressionTree = null;
try
{
this.expressionTree = VisualBasicHelper.Compile(this.ExpressionText, metadata);
}
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
- Point.cs
- StringArrayConverter.cs
- Rectangle.cs
- LineServicesRun.cs
- FieldMetadata.cs
- RealizationDrawingContextWalker.cs
- Activation.cs
- TableColumnCollection.cs
- State.cs
- TextSelection.cs
- TextFormatter.cs
- ResourcesChangeInfo.cs
- BroadcastEventHelper.cs
- webbrowsersite.cs
- RuntimeVariableList.cs
- SchemaImporterExtensionElement.cs
- RSAPKCS1SignatureDeformatter.cs
- ProvidersHelper.cs
- InputBinder.cs
- ResourcesChangeInfo.cs
- ExpressionNode.cs
- RegisteredExpandoAttribute.cs
- webbrowsersite.cs
- Compress.cs
- EventSinkHelperWriter.cs
- DataListCommandEventArgs.cs
- EntityClassGenerator.cs
- SmtpReplyReader.cs
- TemplateBindingExpressionConverter.cs
- HelpKeywordAttribute.cs
- DesignOnlyAttribute.cs
- storepermission.cs
- SafeRightsManagementHandle.cs
- WhitespaceRuleLookup.cs
- ListViewItem.cs
- XmlTextReader.cs
- TreeView.cs
- HtmlInputControl.cs
- Comparer.cs
- OleDbException.cs
- OutOfProcStateClientManager.cs
- RequestQueryParser.cs
- OleDbPermission.cs
- DriveInfo.cs
- TCEAdapterGenerator.cs
- DataKey.cs
- MulticastNotSupportedException.cs
- FontWeightConverter.cs
- ConfigurationErrorsException.cs
- OpenFileDialog.cs
- FacetChecker.cs
- XmlSerializationWriter.cs
- AmbientProperties.cs
- GenericEnumerator.cs
- SponsorHelper.cs
- InfoCardAsymmetricCrypto.cs
- ColorAnimation.cs
- ObjectSecurityT.cs
- EndEvent.cs
- UiaCoreTypesApi.cs
- NonDualMessageSecurityOverHttp.cs
- BuilderInfo.cs
- webeventbuffer.cs
- XamlRtfConverter.cs
- Effect.cs
- DataControlField.cs
- Activation.cs
- InternalsVisibleToAttribute.cs
- TextDecoration.cs
- BitmapSource.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- StandardToolWindows.cs
- WorkflowQueuingService.cs
- HitTestWithPointDrawingContextWalker.cs
- AuthenticationConfig.cs
- RequestResponse.cs
- TrustManagerMoreInformation.cs
- CodeIdentifiers.cs
- DynamicResourceExtensionConverter.cs
- PolicyException.cs
- SHA1CryptoServiceProvider.cs
- BindValidator.cs
- PerformanceCounterLib.cs
- KeyEvent.cs
- KeyEvent.cs
- IndexedEnumerable.cs
- XsdBuildProvider.cs
- TransformerConfigurationWizardBase.cs
- SafeArrayRankMismatchException.cs
- CacheRequest.cs
- DataGridViewRowHeaderCell.cs
- BookmarkEventArgs.cs
- _NegoStream.cs
- FacetEnabledSchemaElement.cs
- NonClientArea.cs
- ConfigurationStrings.cs
- EmbeddedMailObjectsCollection.cs
- DbConnectionPoolOptions.cs
- DesignerAutoFormatStyle.cs
- XmlArrayItemAttributes.cs