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
- ScrollEventArgs.cs
- InvokeBase.cs
- DataTableTypeConverter.cs
- SystemSounds.cs
- HttpRequest.cs
- CustomAssemblyResolver.cs
- XmlILStorageConverter.cs
- CommonRemoteMemoryBlock.cs
- LogExtentCollection.cs
- Positioning.cs
- StoreItemCollection.Loader.cs
- SqlDataSourceStatusEventArgs.cs
- CustomErrorsSection.cs
- ControlBindingsCollection.cs
- GeometryConverter.cs
- HtmlButton.cs
- ChangeProcessor.cs
- SQLBinary.cs
- xsdvalidator.cs
- AnimationException.cs
- Rectangle.cs
- Simplifier.cs
- PropertyTab.cs
- CombinedGeometry.cs
- SHA512.cs
- AnonymousIdentificationModule.cs
- AssociationSet.cs
- RayMeshGeometry3DHitTestResult.cs
- WsdlExporter.cs
- Parser.cs
- Calendar.cs
- TargetControlTypeCache.cs
- Msec.cs
- FrameSecurityDescriptor.cs
- KoreanLunisolarCalendar.cs
- IndexedSelectQueryOperator.cs
- Mappings.cs
- XmlUtf8RawTextWriter.cs
- Logging.cs
- EntityTemplateUserControl.cs
- XmlSchemaAll.cs
- DrawingState.cs
- XmlAggregates.cs
- QilInvokeEarlyBound.cs
- RequestCache.cs
- filewebresponse.cs
- EntitySetDataBindingList.cs
- WebPartMenuStyle.cs
- ToolstripProfessionalRenderer.cs
- XmlArrayItemAttributes.cs
- Config.cs
- XD.cs
- XmlTextReaderImplHelpers.cs
- mediapermission.cs
- newinstructionaction.cs
- CodeGenerator.cs
- DynamicQueryableWrapper.cs
- SharedUtils.cs
- TraceEventCache.cs
- SyndicationSerializer.cs
- CmsInterop.cs
- SettingsAttributes.cs
- PathFigure.cs
- MouseActionConverter.cs
- COM2IDispatchConverter.cs
- MonitorWrapper.cs
- StreamGeometry.cs
- TrackBar.cs
- XmlUtil.cs
- ViewgenGatekeeper.cs
- CheckBoxBaseAdapter.cs
- CodeTypeParameterCollection.cs
- CommandCollectionEditor.cs
- GridViewColumnCollectionChangedEventArgs.cs
- BrowserInteropHelper.cs
- DirectoryRootQuery.cs
- Point3DValueSerializer.cs
- ImpersonationContext.cs
- EventProvider.cs
- ProfileGroupSettings.cs
- ColorAnimationBase.cs
- ValidationPropertyAttribute.cs
- ImageMap.cs
- ObjectDataSourceWizardForm.cs
- _TimerThread.cs
- TableStyle.cs
- ProviderBase.cs
- InputBinder.cs
- AutoGeneratedFieldProperties.cs
- PixelShader.cs
- PinnedBufferMemoryStream.cs
- TransactionProxy.cs
- QilInvoke.cs
- mediaclock.cs
- FilterRepeater.cs
- ListItem.cs
- CultureNotFoundException.cs
- DataAdapter.cs
- InternalDispatchObject.cs
- Double.cs