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
- Config.cs
- ResourcesBuildProvider.cs
- HatchBrush.cs
- KeyedCollection.cs
- ObjectPersistData.cs
- TemplatedEditableDesignerRegion.cs
- ProxyAttribute.cs
- ReferenceEqualityComparer.cs
- TiffBitmapDecoder.cs
- TextDecorationCollection.cs
- FormViewModeEventArgs.cs
- LongSumAggregationOperator.cs
- DynamicActivityProperty.cs
- _ListenerAsyncResult.cs
- ToolStripDropDownButton.cs
- RegularExpressionValidator.cs
- ReferenceService.cs
- ApplicationBuildProvider.cs
- OutputCacheSection.cs
- RegistrySecurity.cs
- RootProfilePropertySettingsCollection.cs
- RootProjectionNode.cs
- XmlSchemaSubstitutionGroup.cs
- SqlEnums.cs
- LocalServiceSecuritySettings.cs
- HttpCapabilitiesBase.cs
- Track.cs
- TypeConverterMarkupExtension.cs
- CryptographicAttribute.cs
- ResourceDictionary.cs
- Delegate.cs
- CustomAttributeSerializer.cs
- FamilyMap.cs
- DbConnectionPoolGroupProviderInfo.cs
- LeaseManager.cs
- ContentPresenter.cs
- SerializerDescriptor.cs
- InternalTransaction.cs
- ResetableIterator.cs
- ExpressionBindingCollection.cs
- SiteMapDataSourceView.cs
- QueryOutputWriter.cs
- RegexReplacement.cs
- SpecularMaterial.cs
- SessionStateItemCollection.cs
- Vector3DCollectionConverter.cs
- NativeRecognizer.cs
- XmlQueryContext.cs
- DataGridViewToolTip.cs
- DistinctQueryOperator.cs
- ScrollChangedEventArgs.cs
- DataGridViewHitTestInfo.cs
- TemplateParser.cs
- XmlEncodedRawTextWriter.cs
- UICuesEvent.cs
- SizeChangedInfo.cs
- PolicyValidationException.cs
- PointCollection.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- ContentPresenter.cs
- Dictionary.cs
- Int16AnimationUsingKeyFrames.cs
- TextRange.cs
- XmlCollation.cs
- DiscriminatorMap.cs
- InputMethodStateTypeInfo.cs
- BezierSegment.cs
- ActivationServices.cs
- ForeignKeyConstraint.cs
- PropertyDescriptors.cs
- XmlQualifiedNameTest.cs
- DrawingContextDrawingContextWalker.cs
- Helper.cs
- DbConnectionInternal.cs
- StyleXamlTreeBuilder.cs
- MemberListBinding.cs
- baseaxisquery.cs
- HtmlInputRadioButton.cs
- ReferenceConverter.cs
- FileDataSourceCache.cs
- Shape.cs
- XMLDiffLoader.cs
- StringFormat.cs
- ProcessModelInfo.cs
- ProcessExitedException.cs
- TimersDescriptionAttribute.cs
- XmlSignificantWhitespace.cs
- ProjectionPlan.cs
- FormsAuthenticationEventArgs.cs
- EdmToObjectNamespaceMap.cs
- DataIdProcessor.cs
- ClientViaElement.cs
- GeneralTransform2DTo3DTo2D.cs
- CopyAttributesAction.cs
- FunctionParameter.cs
- TypeSemantics.cs
- SafeEventLogWriteHandle.cs
- IChannel.cs
- Preprocessor.cs
- COM2ColorConverter.cs