Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Expressions / LambdaValue.cs / 1305376 / LambdaValue.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Expressions { using System; using System.Activities.ExpressionParser; using System.Activities.XamlIntegration; using System.Collections.Generic; using System.Linq.Expressions; using System.Runtime; using System.Windows.Markup; // consciously not XAML-friendly since Linq Expressions aren't create-set-use [Fx.Tag.XamlVisible(false)] public sealed class LambdaValue: CodeActivity , IExpressionContainer, IValueSerializableExpression { Func compiledLambdaValue; Expression > lambdaValue; Expression > rewrittenTree; public LambdaValue(Expression > lambdaValue) { Fx.Assert(lambdaValue != null, "valueExpression should not be null"); this.lambdaValue = lambdaValue; this.SkipArgumentResolution = true; } Expression IExpressionContainer.Expression { get { return this.lambdaValue; } } protected override void CacheMetadata(CodeActivityMetadata metadata) { // We need to rewrite the tree. Expression newTree; if (ExpressionUtilities.TryRewriteLambdaExpression(this.lambdaValue, out newTree, metadata)) { this.rewrittenTree = (Expression >)newTree; } else { this.rewrittenTree = this.lambdaValue; } } internal override bool TryGetValue(ActivityContext context, out TResult value) { if (this.compiledLambdaValue == null) { this.compiledLambdaValue = this.rewrittenTree.Compile(); } value = this.compiledLambdaValue(context); return true; } protected override TResult Execute(CodeActivityContext context) { return ExecuteWithTryGetValue(context); } public bool CanConvertToString(IValueSerializerContext context) { return true; } public string ConvertToString(IValueSerializerContext context) { // This workflow contains lambda expressions specified in code. // These expressions are not XAML serializable. // In order to make your workflow XAML-serializable, // use either VisualBasicValue/Reference or ExpressionServices.Convert // This will convert your lambda expressions into expression activities. throw FxTrace.Exception.AsError(new LambdaSerializationException()); } } } // 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
- _TransmitFileOverlappedAsyncResult.cs
- InkCollectionBehavior.cs
- MetadataWorkspace.cs
- ConditionValidator.cs
- CodeSnippetExpression.cs
- EntityType.cs
- XpsPartBase.cs
- XsltQilFactory.cs
- AssociationType.cs
- AsyncPostBackErrorEventArgs.cs
- SHA512.cs
- CompiledRegexRunnerFactory.cs
- MetadataWorkspace.cs
- AmbiguousMatchException.cs
- TouchesOverProperty.cs
- RelationshipNavigation.cs
- SynchronizationContext.cs
- XamlFigureLengthSerializer.cs
- PageHandlerFactory.cs
- HierarchicalDataBoundControlAdapter.cs
- StatusBar.cs
- InkCanvas.cs
- AdornedElementPlaceholder.cs
- HtmlEncodedRawTextWriter.cs
- NavigationFailedEventArgs.cs
- CqlWriter.cs
- SizeFConverter.cs
- RuleCache.cs
- ReturnType.cs
- BaseHashHelper.cs
- ScriptManagerProxy.cs
- PropertyItemInternal.cs
- DataGridLengthConverter.cs
- HandlerFactoryCache.cs
- ExtendedTransformFactory.cs
- WebPartDisplayModeCancelEventArgs.cs
- ColumnBinding.cs
- indexingfiltermarshaler.cs
- FieldDescriptor.cs
- DataFieldCollectionEditor.cs
- ReplyChannel.cs
- DoWorkEventArgs.cs
- TextFormatterContext.cs
- HostingEnvironmentSection.cs
- BindingUtils.cs
- MouseGestureConverter.cs
- XmlSchemaComplexContentRestriction.cs
- PeerNameRegistration.cs
- RSAPKCS1SignatureDeformatter.cs
- EntityContainerEntitySet.cs
- DataComponentGenerator.cs
- CancellationTokenRegistration.cs
- AttachedAnnotationChangedEventArgs.cs
- MemberMaps.cs
- GradientPanel.cs
- SchemaCollectionCompiler.cs
- SubMenuStyleCollection.cs
- TypeConverter.cs
- XsltLoader.cs
- _LocalDataStore.cs
- ComplexObject.cs
- DirectoryInfo.cs
- XmlSchemaIdentityConstraint.cs
- ConsoleKeyInfo.cs
- hresults.cs
- EventLogPermissionAttribute.cs
- XmlAttributeHolder.cs
- ComplexPropertyEntry.cs
- Debugger.cs
- EditorServiceContext.cs
- ProtocolsConfigurationEntry.cs
- NativeMethods.cs
- WebPartMovingEventArgs.cs
- AnnotationAdorner.cs
- TemplateAction.cs
- Visual3D.cs
- XmlFormatReaderGenerator.cs
- SecureEnvironment.cs
- MarkupCompilePass2.cs
- PeerResolver.cs
- UpdateCompiler.cs
- ProgressiveCrcCalculatingStream.cs
- ContextProperty.cs
- LinkClickEvent.cs
- LowerCaseStringConverter.cs
- EFAssociationProvider.cs
- SharedStatics.cs
- PageContent.cs
- RtType.cs
- FilteredXmlReader.cs
- RecognitionEventArgs.cs
- LocalBuilder.cs
- XmlSchemaDocumentation.cs
- SafeLocalMemHandle.cs
- BasicKeyConstraint.cs
- RelationshipConverter.cs
- RefType.cs
- DataGridViewCellParsingEventArgs.cs
- PassportAuthentication.cs
- ConstrainedDataObject.cs