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
- EdmRelationshipRoleAttribute.cs
- SwitchLevelAttribute.cs
- UnmanagedBitmapWrapper.cs
- ReleaseInstanceMode.cs
- MarkupCompiler.cs
- WebPartCollection.cs
- BufferBuilder.cs
- HiddenField.cs
- TemplatedWizardStep.cs
- ClientConfigPaths.cs
- StateBag.cs
- localization.cs
- Query.cs
- ToolStripGripRenderEventArgs.cs
- ListViewItemMouseHoverEvent.cs
- DependencyObjectType.cs
- DataRowCollection.cs
- BuildProvider.cs
- SessionState.cs
- ButtonColumn.cs
- XmlCodeExporter.cs
- Semaphore.cs
- SafeNativeMethods.cs
- SemanticTag.cs
- GlyphingCache.cs
- BitmapFrameEncode.cs
- ComPlusTypeLoader.cs
- HtmlSelect.cs
- Boolean.cs
- TextEditorSelection.cs
- HtmlInputPassword.cs
- PropertyInformation.cs
- StatusBarPanel.cs
- MappingMetadataHelper.cs
- ClassHandlersStore.cs
- AnnotationHighlightLayer.cs
- ImageCodecInfoPrivate.cs
- ScaleTransform3D.cs
- Soap12ServerProtocol.cs
- Config.cs
- NumericUpDownAcceleration.cs
- SqlProviderServices.cs
- BitConverter.cs
- SafeWaitHandle.cs
- HttpRuntime.cs
- RecognizerBase.cs
- MatrixIndependentAnimationStorage.cs
- RoutedPropertyChangedEventArgs.cs
- TokenBasedSet.cs
- RequestCacheValidator.cs
- VisualCollection.cs
- ConstructorNeedsTagAttribute.cs
- JsonObjectDataContract.cs
- IteratorFilter.cs
- ElementNotEnabledException.cs
- DocumentGridPage.cs
- Point3DAnimationBase.cs
- XmlStringTable.cs
- SerializerWriterEventHandlers.cs
- SimpleApplicationHost.cs
- QilIterator.cs
- RootProfilePropertySettingsCollection.cs
- ResourceSet.cs
- ButtonRenderer.cs
- XmlCountingReader.cs
- Visual3D.cs
- _HelperAsyncResults.cs
- BlurBitmapEffect.cs
- HierarchicalDataSourceDesigner.cs
- ToolboxComponentsCreatedEventArgs.cs
- RootBrowserWindow.cs
- StylusShape.cs
- WebBrowserSiteBase.cs
- CoreChannel.cs
- cryptoapiTransform.cs
- Int32AnimationBase.cs
- TextEditorLists.cs
- BindingNavigator.cs
- StylusPointProperties.cs
- XPathMessageFilter.cs
- Padding.cs
- GridViewDeleteEventArgs.cs
- IriParsingElement.cs
- HtmlTableRow.cs
- ClosableStream.cs
- ResourceExpressionBuilder.cs
- TextLine.cs
- InternalSafeNativeMethods.cs
- DataReceivedEventArgs.cs
- PreservationFileWriter.cs
- TabControlAutomationPeer.cs
- SQLInt16.cs
- IdentitySection.cs
- ManagementBaseObject.cs
- DbgUtil.cs
- LineInfo.cs
- AbandonedMutexException.cs
- XsdValidatingReader.cs
- TextTreeTextNode.cs
- StrokeCollectionDefaultValueFactory.cs