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 InArgument Reason { 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
- _AutoWebProxyScriptEngine.cs
- SQLInt32Storage.cs
- HorizontalAlignConverter.cs
- BinHexDecoder.cs
- SplayTreeNode.cs
- MetabaseSettingsIis7.cs
- errorpatternmatcher.cs
- Selector.cs
- NoneExcludedImageIndexConverter.cs
- EntityDataSourceMemberPath.cs
- IndicFontClient.cs
- CompositeScriptReferenceEventArgs.cs
- ConfigurationManagerHelperFactory.cs
- Matrix3DConverter.cs
- DataBoundControlAdapter.cs
- EdmFunctionAttribute.cs
- ListViewItemEventArgs.cs
- PrePrepareMethodAttribute.cs
- IisTraceWebEventProvider.cs
- ValidationSummary.cs
- FormDesigner.cs
- ServiceDescriptionImporter.cs
- storepermission.cs
- ButtonBaseAdapter.cs
- XmlExpressionDumper.cs
- ApplicationManager.cs
- CoTaskMemSafeHandle.cs
- DistinctQueryOperator.cs
- Random.cs
- isolationinterop.cs
- TextParaClient.cs
- PersonalizationStateQuery.cs
- WorkflowApplicationUnhandledExceptionEventArgs.cs
- SqlNodeTypeOperators.cs
- InertiaExpansionBehavior.cs
- XmlDownloadManager.cs
- Token.cs
- ImportContext.cs
- ListViewSortEventArgs.cs
- ObjectSet.cs
- BindingContext.cs
- DrawingGroup.cs
- ICspAsymmetricAlgorithm.cs
- InterleavedZipPartStream.cs
- ItemCollection.cs
- BuildManagerHost.cs
- EditingCommands.cs
- ConfigXmlComment.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- SspiWrapper.cs
- TagNameToTypeMapper.cs
- AndCondition.cs
- ListViewHitTestInfo.cs
- ServiceProviders.cs
- DBSchemaRow.cs
- RouteItem.cs
- DateTimeParse.cs
- LoginUtil.cs
- ipaddressinformationcollection.cs
- FormViewRow.cs
- HandlerBase.cs
- TableRowGroupCollection.cs
- DataObjectFieldAttribute.cs
- SqlFunctionAttribute.cs
- DataGridViewTextBoxEditingControl.cs
- Stack.cs
- GridEntry.cs
- GridItemCollection.cs
- CmsInterop.cs
- HashSetDebugView.cs
- _NegoStream.cs
- HandlerMappingMemo.cs
- WebPartConnectionsDisconnectVerb.cs
- SafeMemoryMappedFileHandle.cs
- UnhandledExceptionEventArgs.cs
- CmsUtils.cs
- DateTimeFormatInfoScanner.cs
- SecUtil.cs
- WebScriptServiceHostFactory.cs
- FieldInfo.cs
- DataViewSetting.cs
- XmlBoundElement.cs
- CompilationSection.cs
- WebPartCatalogAddVerb.cs
- ZipIOExtraField.cs
- EntityDataSourceChangingEventArgs.cs
- X509ChainPolicy.cs
- SymLanguageVendor.cs
- PointConverter.cs
- WindowsListViewItemCheckBox.cs
- TemplateBindingExtension.cs
- BinaryObjectReader.cs
- OwnerDrawPropertyBag.cs
- TypeDescriptionProvider.cs
- AutoCompleteStringCollection.cs
- CodeStatement.cs
- QuaternionKeyFrameCollection.cs
- GeometryValueSerializer.cs
- LeafCellTreeNode.cs
- ContextActivityUtils.cs