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
- SchemeSettingElementCollection.cs
- BindToObject.cs
- securitycriticaldataClass.cs
- NetworkAddressChange.cs
- Identity.cs
- XmlTextAttribute.cs
- XamlWriterExtensions.cs
- AnnotationObservableCollection.cs
- ExpressionPrefixAttribute.cs
- FontWeights.cs
- TransactionContextManager.cs
- WindowsFormsSectionHandler.cs
- DataTableReaderListener.cs
- PropertyChangeTracker.cs
- VirtualizingStackPanel.cs
- WebScriptMetadataMessage.cs
- ProjectedSlot.cs
- HttpRequest.cs
- IPPacketInformation.cs
- PtsContext.cs
- GridItemProviderWrapper.cs
- ParameterInfo.cs
- TabItemAutomationPeer.cs
- RedBlackList.cs
- SqlConnectionManager.cs
- connectionpool.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- EventLogPermissionAttribute.cs
- ImageClickEventArgs.cs
- BoolExpr.cs
- XmlParserContext.cs
- ToolboxItem.cs
- SqlWriter.cs
- ClrPerspective.cs
- WebPartZone.cs
- OpCellTreeNode.cs
- ArithmeticException.cs
- HtmlElementCollection.cs
- _ScatterGatherBuffers.cs
- CorrelationKey.cs
- Control.cs
- XmlStreamStore.cs
- HyperLinkDataBindingHandler.cs
- Expressions.cs
- CodeDOMUtility.cs
- OutputCacheSettings.cs
- followingsibling.cs
- InputBindingCollection.cs
- DataBindingValueUIHandler.cs
- SizeLimitedCache.cs
- CapabilitiesState.cs
- XmlSchemaValidator.cs
- WindowsGraphicsWrapper.cs
- ColumnTypeConverter.cs
- EventLogEntryCollection.cs
- CodeAccessPermission.cs
- InternalBufferOverflowException.cs
- SrgsElementList.cs
- RectIndependentAnimationStorage.cs
- PropertyTabAttribute.cs
- BinHexEncoding.cs
- ApplicationDirectoryMembershipCondition.cs
- XmlArrayAttribute.cs
- ConsumerConnectionPoint.cs
- XmlSchemaNotation.cs
- DataControlImageButton.cs
- SettingsPropertyValue.cs
- FileVersion.cs
- DataGridViewComboBoxEditingControl.cs
- TriState.cs
- SoapAttributeAttribute.cs
- Debug.cs
- XmlSchemaAnnotation.cs
- FieldNameLookup.cs
- CommonDialog.cs
- XmlEnumAttribute.cs
- ObjectNavigationPropertyMapping.cs
- HMACSHA256.cs
- XmlNavigatorStack.cs
- ForEachAction.cs
- DataBindEngine.cs
- TrackPoint.cs
- LassoSelectionBehavior.cs
- CSharpCodeProvider.cs
- ExpressionContext.cs
- HierarchicalDataSourceConverter.cs
- ToolStripItemImageRenderEventArgs.cs
- SizeLimitedCache.cs
- ReferenceEqualityComparer.cs
- PropertyPushdownHelper.cs
- XmlSchemaComplexContentRestriction.cs
- ObfuscateAssemblyAttribute.cs
- NavigationCommands.cs
- PeerApplicationLaunchInfo.cs
- PageCodeDomTreeGenerator.cs
- dsa.cs
- ObjectHandle.cs
- RuntimeConfigurationRecord.cs
- Point3DCollection.cs
- XmlSerializerAssemblyAttribute.cs