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
- EmbossBitmapEffect.cs
- SchemaMapping.cs
- CompilerTypeWithParams.cs
- EnumValAlphaComparer.cs
- DataGridViewLinkColumn.cs
- ImageField.cs
- WmpBitmapEncoder.cs
- CacheRequest.cs
- TabItemAutomationPeer.cs
- ItemCollection.cs
- ButtonChrome.cs
- JoinGraph.cs
- TableLayoutPanelDesigner.cs
- AuthenticationServiceManager.cs
- PixelShader.cs
- SRGSCompiler.cs
- HuffmanTree.cs
- BypassElement.cs
- KeyboardInputProviderAcquireFocusEventArgs.cs
- ClonableStack.cs
- GroupBoxRenderer.cs
- SmtpLoginAuthenticationModule.cs
- SecurityContext.cs
- UIElementPropertyUndoUnit.cs
- PrintController.cs
- WebPartDisplayModeCollection.cs
- XmlResolver.cs
- PropertyDescriptorCollection.cs
- SlotInfo.cs
- IDQuery.cs
- PerformanceCounterNameAttribute.cs
- DataTableNameHandler.cs
- CallInfo.cs
- SessionStateUtil.cs
- ChangePassword.cs
- Thread.cs
- WebUtil.cs
- MessagePartDescription.cs
- ChildDocumentBlock.cs
- CompoundFileStreamReference.cs
- ExceptionTranslationTable.cs
- StringUtil.cs
- mactripleDES.cs
- FixedTextSelectionProcessor.cs
- PersonalizationStateQuery.cs
- AppDomain.cs
- RegexCapture.cs
- FontCollection.cs
- ServiceControllerDesigner.cs
- ActivityBuilderHelper.cs
- SqlDataSourceView.cs
- DragStartedEventArgs.cs
- ParagraphVisual.cs
- RuleInfoComparer.cs
- CommonDialog.cs
- RepeatButton.cs
- UpWmlPageAdapter.cs
- XmlAttribute.cs
- ResourcePool.cs
- Ops.cs
- ConnectionModeReader.cs
- ClassHandlersStore.cs
- MailMessageEventArgs.cs
- LinearGradientBrush.cs
- ReadWriteControlDesigner.cs
- FilterException.cs
- PropertyGridEditorPart.cs
- WeakReferenceList.cs
- XmlCountingReader.cs
- MobileSysDescriptionAttribute.cs
- BigInt.cs
- DataViewSetting.cs
- Timer.cs
- LogLogRecordEnumerator.cs
- ToolStripManager.cs
- StrokeIntersection.cs
- AnnotationService.cs
- Menu.cs
- ItemsControl.cs
- RequestQueue.cs
- HierarchicalDataSourceConverter.cs
- DataTrigger.cs
- ScrollItemProviderWrapper.cs
- DaylightTime.cs
- ProcessHostServerConfig.cs
- SerializationSectionGroup.cs
- InsufficientExecutionStackException.cs
- RuntimeConfig.cs
- SessionState.cs
- XhtmlBasicLabelAdapter.cs
- TdsEnums.cs
- Validator.cs
- RoleManagerSection.cs
- ProtocolViolationException.cs
- HttpPostedFile.cs
- ChtmlMobileTextWriter.cs
- SimpleApplicationHost.cs
- QueryCacheManager.cs
- SdlChannelSink.cs
- CompensatableTransactionScopeActivityDesigner.cs