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
- ImportCatalogPart.cs
- XsdDateTime.cs
- ClientFormsAuthenticationCredentials.cs
- XmlSortKeyAccumulator.cs
- ModelPerspective.cs
- ActivityInfo.cs
- ComponentChangedEvent.cs
- MatrixKeyFrameCollection.cs
- ApplicationServicesHostFactory.cs
- MinimizableAttributeTypeConverter.cs
- FormsAuthenticationUserCollection.cs
- SystemTcpStatistics.cs
- Accessors.cs
- COM2ColorConverter.cs
- RadioButtonList.cs
- ExpressionParser.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- ImmComposition.cs
- Msec.cs
- ToolTipService.cs
- TextContainer.cs
- ScopelessEnumAttribute.cs
- PixelShader.cs
- GlyphElement.cs
- DrawingContextWalker.cs
- XmlHierarchicalEnumerable.cs
- DoubleStorage.cs
- ContainerParagraph.cs
- RegexInterpreter.cs
- RequestResizeEvent.cs
- LinearKeyFrames.cs
- CssStyleCollection.cs
- TreeNodeStyle.cs
- WindowsTab.cs
- SmtpTransport.cs
- BitArray.cs
- DependencyObjectPropertyDescriptor.cs
- SystemUdpStatistics.cs
- FilteredXmlReader.cs
- GeneratedCodeAttribute.cs
- WeakReference.cs
- HostedAspNetEnvironment.cs
- WindowsUpDown.cs
- Graph.cs
- RawStylusInputCustomData.cs
- SID.cs
- CodeAttributeArgument.cs
- shaperfactory.cs
- BaseDataList.cs
- Size.cs
- CodePageUtils.cs
- GlyphShapingProperties.cs
- ThemeDirectoryCompiler.cs
- _HelperAsyncResults.cs
- CompositeDataBoundControl.cs
- SafeHandle.cs
- MimeTypeMapper.cs
- ModulesEntry.cs
- HttpVersion.cs
- DataFormats.cs
- RecognizedWordUnit.cs
- FilterableData.cs
- ProfileParameter.cs
- DataBindingsDialog.cs
- xml.cs
- PropertyTabAttribute.cs
- ReversePositionQuery.cs
- EntityClientCacheEntry.cs
- BeginEvent.cs
- Page.cs
- ThreadPool.cs
- DataFormats.cs
- VariantWrapper.cs
- XmlSchemaImport.cs
- MulticastOption.cs
- KeyConstraint.cs
- InputScopeAttribute.cs
- ContainerParagraph.cs
- CacheModeValueSerializer.cs
- BreakSafeBase.cs
- XamlTreeBuilder.cs
- MemberListBinding.cs
- ActivationServices.cs
- MarshalByValueComponent.cs
- Timer.cs
- Dictionary.cs
- UrlParameterWriter.cs
- SelectionHighlightInfo.cs
- TabItem.cs
- ToolBarButtonDesigner.cs
- LookupBindingPropertiesAttribute.cs
- TableLayoutStyleCollection.cs
- SrgsElementFactory.cs
- MsmqIntegrationReceiveParameters.cs
- RelatedView.cs
- TreeView.cs
- WebHeaderCollection.cs
- RefExpr.cs
- PhysicalAddress.cs
- GraphicsContext.cs