Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Expressions / Multiply.cs / 1305376 / Multiply.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Expressions { using System.Activities; using System.Activities.Statements; using System.Linq.Expressions; using System.Activities.Validation; using System.Collections.Generic; using System.ComponentModel; using System.Runtime; public sealed class Multiply: CodeActivity { //Lock is not needed for operationFunction here. The reason is that delegates for a given Multiply are the same. //It's possible that 2 threads are assigning the operationFucntion at the same time. But it's okay because the compiled codes are the same. static Func checkedOperationFunction; static Func uncheckedOperationFunction; bool checkedOperation = true; [RequiredArgument] [DefaultValue(null)] public InArgument Left { get; set; } [RequiredArgument] [DefaultValue(null)] public InArgument Right { get; set; } [DefaultValue(true)] public bool Checked { get { return this.checkedOperation; } set { this.checkedOperation = value; } } protected override void CacheMetadata(CodeActivityMetadata metadata) { BinaryExpressionHelper.OnGetArguments(metadata, this.Left, this.Right); if (this.checkedOperation) { EnsureOperationFunction(metadata, ref checkedOperationFunction, ExpressionType.MultiplyChecked); } else { EnsureOperationFunction(metadata, ref uncheckedOperationFunction, ExpressionType.Multiply); } } void EnsureOperationFunction(CodeActivityMetadata metadata, ref Func operationFunction, ExpressionType operatorType) { if (operationFunction == null) { ValidationError validationError; if (!BinaryExpressionHelper.TryGenerateLinqDelegate( operatorType, out operationFunction, out validationError)) { metadata.AddValidationError(validationError); } } } protected override TResult Execute(CodeActivityContext context) { TLeft leftValue = this.Left.Get(context); TRight rightValue = this.Right.Get(context); //if user changed Checked flag between Open and Execution, //a NRE may be thrown and that's by design if (this.checkedOperation) { return checkedOperationFunction(leftValue, rightValue); } else { return uncheckedOperationFunction(leftValue, rightValue); } } } } // 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
- ColorTransformHelper.cs
- DataListItemEventArgs.cs
- SamlAssertion.cs
- ColorTransform.cs
- DataGrid.cs
- ServiceDebugElement.cs
- XmlSchemaSimpleTypeUnion.cs
- LongTypeConverter.cs
- ExtensionFile.cs
- DataGridCaption.cs
- HiddenFieldPageStatePersister.cs
- DelegateSerializationHolder.cs
- DelayLoadType.cs
- DateTimeFormatInfo.cs
- BevelBitmapEffect.cs
- HTTPNotFoundHandler.cs
- X509ScopedServiceCertificateElementCollection.cs
- Errors.cs
- ImageSourceValueSerializer.cs
- SystemDropShadowChrome.cs
- ResourcesBuildProvider.cs
- complextypematerializer.cs
- ObjectViewQueryResultData.cs
- TrackingRecord.cs
- XmlIlVisitor.cs
- HttpDictionary.cs
- BlockCollection.cs
- Queue.cs
- BitmapEffectGroup.cs
- ToolStripItemEventArgs.cs
- SafeRsaProviderHandle.cs
- TextEditorLists.cs
- XmlEncodedRawTextWriter.cs
- Point3DCollection.cs
- XslCompiledTransform.cs
- InstanceNotReadyException.cs
- AnimationClockResource.cs
- PersonalizationProviderHelper.cs
- ValidationManager.cs
- Comparer.cs
- filewebresponse.cs
- QueryCacheKey.cs
- Transform.cs
- DefaultBinder.cs
- unitconverter.cs
- WebChannelFactory.cs
- DecoderReplacementFallback.cs
- HtmlPhoneCallAdapter.cs
- SafeNativeMethodsMilCoreApi.cs
- ExtendLockCommand.cs
- SettingsSavedEventArgs.cs
- mediaeventargs.cs
- DropShadowBitmapEffect.cs
- PrintPreviewDialog.cs
- DocumentDesigner.cs
- SQLString.cs
- HttpModuleAction.cs
- InertiaTranslationBehavior.cs
- TextEditorSelection.cs
- InvalidProgramException.cs
- DesignerSerializationOptionsAttribute.cs
- DefaultWorkflowSchedulerService.cs
- CharacterMetrics.cs
- Viewport3DVisual.cs
- MessageQueueInstaller.cs
- CodeExpressionCollection.cs
- SQLSingleStorage.cs
- BodyGlyph.cs
- TextTreeTextNode.cs
- XmlPreloadedResolver.cs
- TextLineBreak.cs
- PreloadHost.cs
- PointKeyFrameCollection.cs
- PageParser.cs
- RootBrowserWindow.cs
- TypeInitializationException.cs
- ToolStripItemRenderEventArgs.cs
- DebugView.cs
- BypassElement.cs
- XmlSerializerAssemblyAttribute.cs
- VirtualizedItemPattern.cs
- ArraySortHelper.cs
- TypeListConverter.cs
- WebServiceTypeData.cs
- AvTraceFormat.cs
- WebConfigurationHostFileChange.cs
- ListBase.cs
- UDPClient.cs
- WebPartZone.cs
- Rotation3DKeyFrameCollection.cs
- CreationContext.cs
- HandleTable.cs
- SizeLimitedCache.cs
- MatrixTransform.cs
- XpsFontSubsetter.cs
- CharacterBufferReference.cs
- ViewCellRelation.cs
- SinglePhaseEnlistment.cs
- EntityDesignerBuildProvider.cs
- DbConnectionPoolIdentity.cs