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
- ObjectManager.cs
- IntSecurity.cs
- SystemInfo.cs
- SafeFindHandle.cs
- XmlDataProvider.cs
- MissingSatelliteAssemblyException.cs
- ObjectDataSourceDisposingEventArgs.cs
- ScriptComponentDescriptor.cs
- HyperLinkField.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- VisualBasicSettingsHandler.cs
- CollectionViewGroupRoot.cs
- BaseComponentEditor.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- Int32CollectionValueSerializer.cs
- TableAdapterManagerMethodGenerator.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- HtmlInputImage.cs
- ToolboxBitmapAttribute.cs
- SchemeSettingElementCollection.cs
- WebPartEventArgs.cs
- ColumnResizeAdorner.cs
- DataGridViewRowHeaderCell.cs
- AdornerLayer.cs
- WebConfigurationFileMap.cs
- RangeValuePattern.cs
- DnsElement.cs
- DrawingImage.cs
- CompiledRegexRunnerFactory.cs
- AppSettingsExpressionBuilder.cs
- RelatedView.cs
- SystemDiagnosticsSection.cs
- ResourceManagerWrapper.cs
- HttpConfigurationContext.cs
- DecimalConstantAttribute.cs
- SqlTypesSchemaImporter.cs
- ConnectionOrientedTransportElement.cs
- InstanceData.cs
- QueryContinueDragEvent.cs
- PropertyReferenceSerializer.cs
- RangeValidator.cs
- DataConnectionHelper.cs
- FixedPageAutomationPeer.cs
- pingexception.cs
- HttpChannelBindingToken.cs
- BindingCompleteEventArgs.cs
- GatewayDefinition.cs
- ArrayElementGridEntry.cs
- UserControlCodeDomTreeGenerator.cs
- HyperLink.cs
- AssemblyResourceLoader.cs
- Transform3DGroup.cs
- BCLDebug.cs
- VirtualizingStackPanel.cs
- DataServiceContext.cs
- DynamicDataManager.cs
- FormsAuthenticationConfiguration.cs
- PerfService.cs
- UIPermission.cs
- BindingValueChangedEventArgs.cs
- DefinitionBase.cs
- ReachDocumentReferenceSerializerAsync.cs
- CaseCqlBlock.cs
- Iis7Helper.cs
- BindingMemberInfo.cs
- HtmlGenericControl.cs
- DiagnosticsConfiguration.cs
- WindowsContainer.cs
- ControllableStoryboardAction.cs
- WriteTimeStream.cs
- CodeGroup.cs
- ValidatorCompatibilityHelper.cs
- DecoratedNameAttribute.cs
- MatrixAnimationBase.cs
- InputLanguageSource.cs
- RelOps.cs
- UnsafeNativeMethods.cs
- DelegatedStream.cs
- DataMisalignedException.cs
- XamlSerializer.cs
- EntityContainerEntitySet.cs
- OleDbCommand.cs
- ExpandSegment.cs
- ParserContext.cs
- HostingEnvironmentSection.cs
- TransformCryptoHandle.cs
- Container.cs
- ThumbAutomationPeer.cs
- AtomMaterializer.cs
- CustomWebEventKey.cs
- SoapMessage.cs
- ParseChildrenAsPropertiesAttribute.cs
- WinInetCache.cs
- FindProgressChangedEventArgs.cs
- SessionPageStatePersister.cs
- HttpBrowserCapabilitiesBase.cs
- IImplicitResourceProvider.cs
- LinearGradientBrush.cs
- LayoutTable.cs
- OleDbDataAdapter.cs