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
- Classification.cs
- MembershipSection.cs
- IriParsingElement.cs
- DataServiceQueryProvider.cs
- SurrogateEncoder.cs
- DiscoveryVersionConverter.cs
- EventHandlerList.cs
- PropertyGrid.cs
- TransactionScope.cs
- PathFigure.cs
- FontFamily.cs
- SerialPort.cs
- Size3DConverter.cs
- ValidationHelper.cs
- InputBindingCollection.cs
- Operators.cs
- documentsequencetextpointer.cs
- ValidatedControlConverter.cs
- WebPartActionVerb.cs
- ManagementObjectCollection.cs
- Timeline.cs
- TextStore.cs
- MediaPlayer.cs
- MemoryMappedFileSecurity.cs
- BamlLocalizableResource.cs
- WriteFileContext.cs
- ObjectViewQueryResultData.cs
- DataGridSortCommandEventArgs.cs
- ProgressBarAutomationPeer.cs
- OutOfMemoryException.cs
- SaveFileDialog.cs
- QueryConverter.cs
- NativeCompoundFileAPIs.cs
- TraceUtils.cs
- ACL.cs
- HostingEnvironmentWrapper.cs
- RegexRunner.cs
- WindowsSlider.cs
- UriSectionData.cs
- LockedHandleGlyph.cs
- ByteAnimationUsingKeyFrames.cs
- DataListItemEventArgs.cs
- DataListItemEventArgs.cs
- _StreamFramer.cs
- DataGridHeadersVisibilityToVisibilityConverter.cs
- PersistenceException.cs
- AnimationClockResource.cs
- ContextActivityUtils.cs
- DataRelationCollection.cs
- TraceContext.cs
- BooleanStorage.cs
- MatcherBuilder.cs
- BrowserDefinitionCollection.cs
- CodeAttributeArgumentCollection.cs
- ActivityExecutorSurrogate.cs
- ViewCellRelation.cs
- Application.cs
- Select.cs
- CoTaskMemUnicodeSafeHandle.cs
- NullExtension.cs
- DoWorkEventArgs.cs
- WebResourceUtil.cs
- PeerCollaboration.cs
- CollectionType.cs
- ApplicationFileParser.cs
- QilFunction.cs
- DataSourceXmlClassAttribute.cs
- DataSysAttribute.cs
- InputLangChangeRequestEvent.cs
- LassoSelectionBehavior.cs
- FontWeight.cs
- TextInfo.cs
- BatchStream.cs
- ApplicationException.cs
- sqlser.cs
- EntityDesignerUtils.cs
- ColumnReorderedEventArgs.cs
- HttpProcessUtility.cs
- DbConnectionHelper.cs
- VectorKeyFrameCollection.cs
- CultureSpecificStringDictionary.cs
- StoreItemCollection.cs
- WithStatement.cs
- Facet.cs
- SoapTypeAttribute.cs
- SignedXml.cs
- Rotation3DAnimationUsingKeyFrames.cs
- SqlClientPermission.cs
- TimelineGroup.cs
- EntityDataSourceState.cs
- TimeSpanSecondsConverter.cs
- RunWorkerCompletedEventArgs.cs
- SystemIcmpV4Statistics.cs
- DataSourceControlBuilder.cs
- RowUpdatingEventArgs.cs
- Process.cs
- CodeNamespaceImportCollection.cs
- HwndSourceParameters.cs
- DataColumn.cs
- objectquery_tresulttype.cs