Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / TerminateWorkflow.cs / 1305376 / TerminateWorkflow.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Statements { using System; using System.Activities; using System.ComponentModel; using System.Collections.ObjectModel; public sealed class TerminateWorkflow : NativeActivity { public TerminateWorkflow() { } [DefaultValue(null)] public InArgumentReason { get; set; } [DefaultValue(null)] public InArgument Exception { get; set; } protected override void CacheMetadata(NativeActivityMetadata metadata) { Collection arguments = new Collection (); RuntimeArgument reasonArgument = new RuntimeArgument("Reason", typeof(string), ArgumentDirection.In, false); metadata.Bind(this.Reason, reasonArgument); RuntimeArgument exceptionArgument = new RuntimeArgument("Exception", typeof(Exception), ArgumentDirection.In, false); metadata.Bind(this.Exception, exceptionArgument); arguments.Add(reasonArgument); arguments.Add(exceptionArgument); metadata.SetArgumentsCollection(arguments); if((this.Reason == null || this.Reason.IsEmpty) && (this.Exception == null || this.Exception.IsEmpty)) { metadata.AddValidationError(SR.OneOfTwoPropertiesMustBeSet("Reason", "Exception", "TerminateWorkflow", this.DisplayName)); } } protected override void Execute(NativeActivityContext context) { // If Reason is provided, we'll create a WorkflowApplicationTerminatedException from // it, wrapping Exception if it is also provided. Otherwise just use Exception. // If neither is provided just throw a new WorkflowTerminatedException. string reason = Reason.Get(context); Exception exception = Exception.Get(context); if (!string.IsNullOrEmpty(reason)) { context.Terminate(new WorkflowTerminatedException(reason, exception)); } else if(exception != null) { context.Terminate(exception); } else { context.Terminate(new WorkflowTerminatedException()); } } } } // 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
- PointCollectionConverter.cs
- DateTimeEditor.cs
- DatePickerDateValidationErrorEventArgs.cs
- WindowsListViewScroll.cs
- TranslateTransform3D.cs
- SqlClientPermission.cs
- PathFigureCollection.cs
- SerializationHelper.cs
- DataBindingCollection.cs
- OleDbRowUpdatedEvent.cs
- DependencyObjectValidator.cs
- HighlightComponent.cs
- ColorTranslator.cs
- UInt16Converter.cs
- MsmqHostedTransportConfiguration.cs
- CollectionViewGroup.cs
- OracleTimeSpan.cs
- WebBrowserDocumentCompletedEventHandler.cs
- SQLString.cs
- WinFormsSpinner.cs
- ToolStripItemImageRenderEventArgs.cs
- TypeBuilderInstantiation.cs
- ProcessingInstructionAction.cs
- XmlTypeMapping.cs
- Converter.cs
- Visual3D.cs
- WbemProvider.cs
- WebBrowsableAttribute.cs
- ResourceExpressionEditor.cs
- ResourceIDHelper.cs
- PasswordBox.cs
- FontStyles.cs
- NavigationPropertyEmitter.cs
- SymbolResolver.cs
- DateBoldEvent.cs
- KoreanLunisolarCalendar.cs
- WindowVisualStateTracker.cs
- SplitContainer.cs
- ProcessProtocolHandler.cs
- NativeActivity.cs
- ListBoxItemAutomationPeer.cs
- FollowerQueueCreator.cs
- HttpCacheParams.cs
- ProfileProvider.cs
- ContainerCodeDomSerializer.cs
- EventLogEntry.cs
- SafePointer.cs
- PermissionToken.cs
- MultiSelector.cs
- IssuanceTokenProviderBase.cs
- FormCollection.cs
- UnsafePeerToPeerMethods.cs
- FontWeight.cs
- RegistryExceptionHelper.cs
- BuildManager.cs
- FeatureSupport.cs
- ManipulationStartedEventArgs.cs
- NonSerializedAttribute.cs
- UiaCoreApi.cs
- UnhandledExceptionEventArgs.cs
- CodeCommentStatementCollection.cs
- AdPostCacheSubstitution.cs
- ApplicationException.cs
- FontUnit.cs
- ProcessHostConfigUtils.cs
- entityreference_tresulttype.cs
- DecimalKeyFrameCollection.cs
- FixedPageStructure.cs
- BaseValidator.cs
- TouchesOverProperty.cs
- Transform3D.cs
- assertwrapper.cs
- SocketPermission.cs
- Permission.cs
- ParsedAttributeCollection.cs
- SessionEndingCancelEventArgs.cs
- FixedSOMContainer.cs
- WeakReadOnlyCollection.cs
- ApplicationDirectory.cs
- TableItemStyle.cs
- EntityContainer.cs
- ToolboxComponentsCreatingEventArgs.cs
- DataTableTypeConverter.cs
- DataMisalignedException.cs
- MatrixAnimationUsingKeyFrames.cs
- TimelineClockCollection.cs
- SessionEndedEventArgs.cs
- _UncName.cs
- StringComparer.cs
- WebPartVerb.cs
- UpdateTracker.cs
- InternalControlCollection.cs
- RuleRefElement.cs
- KnownBoxes.cs
- StorageMappingItemCollection.cs
- TraceHwndHost.cs
- UriScheme.cs
- DataGridSortCommandEventArgs.cs
- SQLInt16.cs
- ClockController.cs