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
- XsltSettings.cs
- CodeLinePragma.cs
- SqlConnectionString.cs
- EmptyElement.cs
- FilterElement.cs
- DataServiceExpressionVisitor.cs
- EmbossBitmapEffect.cs
- InputLangChangeEvent.cs
- OutOfProcStateClientManager.cs
- EntityDataSourceChangedEventArgs.cs
- XmlSubtreeReader.cs
- EDesignUtil.cs
- OracleParameterBinding.cs
- NamedElement.cs
- PeerNameRegistration.cs
- KeyToListMap.cs
- ClientApiGenerator.cs
- InputProcessorProfiles.cs
- ObjectListCommandCollection.cs
- ControlCommandSet.cs
- InvalidComObjectException.cs
- SuppressMergeCheckAttribute.cs
- InternalTypeHelper.cs
- LoginName.cs
- UIPropertyMetadata.cs
- WebRequestModulesSection.cs
- Hyperlink.cs
- AnimationException.cs
- EditorPart.cs
- RelationshipDetailsRow.cs
- PerformanceCounterPermissionEntry.cs
- OracleColumn.cs
- Image.cs
- LambdaCompiler.Statements.cs
- JsonReaderDelegator.cs
- CodeCastExpression.cs
- ToolZone.cs
- DrawListViewColumnHeaderEventArgs.cs
- DataTableMappingCollection.cs
- FindCompletedEventArgs.cs
- WindowsListViewGroupHelper.cs
- CategoryAttribute.cs
- ScrollItemProviderWrapper.cs
- XmlSchemaAny.cs
- RenderOptions.cs
- XmlMemberMapping.cs
- EventData.cs
- Int32EqualityComparer.cs
- ProfilePropertySettings.cs
- MetadataImporter.cs
- DropDownButton.cs
- PointCollection.cs
- EmptyEnumerator.cs
- WsatServiceCertificate.cs
- AffineTransform3D.cs
- RegexStringValidator.cs
- CompilerHelpers.cs
- OleServicesContext.cs
- _NativeSSPI.cs
- FixedTextSelectionProcessor.cs
- ECDiffieHellmanPublicKey.cs
- ColorMatrix.cs
- ZipIOCentralDirectoryBlock.cs
- PropertyBuilder.cs
- WhitespaceRuleReader.cs
- AutoFocusStyle.xaml.cs
- WCFModelStrings.Designer.cs
- MetadataPropertyAttribute.cs
- HttpDictionary.cs
- SoapAttributes.cs
- DependencyPropertyChangedEventArgs.cs
- XmlAutoDetectWriter.cs
- CryptoStream.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- Frame.cs
- Processor.cs
- AuthenticationException.cs
- WorkflowApplicationTerminatedException.cs
- __TransparentProxy.cs
- InputProviderSite.cs
- TimelineCollection.cs
- StringConcat.cs
- VirtualPath.cs
- ContentIterators.cs
- DesignerEditorPartChrome.cs
- ControlPaint.cs
- XmlDataSourceNodeDescriptor.cs
- SafeProcessHandle.cs
- CanExecuteRoutedEventArgs.cs
- ProcessModule.cs
- DependencyPropertyChangedEventArgs.cs
- SQLInt16Storage.cs
- PageRouteHandler.cs
- EntryIndex.cs
- ContextStack.cs
- Visual.cs
- SmtpNegotiateAuthenticationModule.cs
- CompModSwitches.cs
- InternalTransaction.cs
- SqlCharStream.cs