Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / CompensationExtension.cs / 1305376 / CompensationExtension.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Statements { using System; using System.Activities.Hosting; using System.Activities.Persistence; using System.Collections.Generic; using System.ComponentModel; using System.Runtime; using System.Xml.Linq; sealed class CompensationExtension : PersistenceParticipant, IWorkflowInstanceExtension { static readonly XNamespace compensationNamespace = XNamespace.Get("urn:schemas-microsoft-com:System.Activities/4.0/compensation"); static readonly XName compensationExtensionData = compensationNamespace.GetName("Data"); [Fx.Tag.SynchronizationObject(Blocking = false)] DictionarycompensationTokenTable; public CompensationExtension() { this.compensationTokenTable = new Dictionary (); } internal Dictionary CompensationTokenTable { get { return this.compensationTokenTable; } private set { this.compensationTokenTable = value; } } internal long Id { get; set; } internal Bookmark WorkflowCompensation { get; set; } internal Bookmark WorkflowConfirmation { get; set; } internal Bookmark WorkflowCompensationScheduled { get; private set; } internal bool IsWorkflowCompensationBehaviorScheduled { get; private set; } internal WorkflowCompensationBehavior WorkflowCompensationBehavior { get; set; } internal WorkflowInstanceProxy Instance { get; private set; } internal void Add(long compensationId, CompensationTokenData compensationToken) { Fx.Assert(compensationToken != null, "compensationToken must be valid"); this.CompensationTokenTable[compensationId] = compensationToken; } internal void Remove(long compensationId) { this.CompensationTokenTable.Remove(compensationId); } internal CompensationTokenData Get(long compensationId) { CompensationTokenData compensationToken = null; this.CompensationTokenTable.TryGetValue(compensationId, out compensationToken); return compensationToken; } internal Bookmark FindBookmark(long compensationId, CompensationBookmarkName bookmarkName) { CompensationTokenData compensationToken = null; Bookmark bookmark = null; if (this.CompensationTokenTable.TryGetValue(compensationId, out compensationToken)) { bookmark = compensationToken.BookmarkTable[bookmarkName]; } return bookmark; } internal void SetupWorkflowCompensationBehavior(NativeActivityContext context, BookmarkCallback callback) { this.WorkflowCompensationScheduled = context.CreateBookmark(callback); Fx.Assert(this.WorkflowCompensationBehavior != null, "WorkflowCompensationBehavior must be valid"); context.ScheduleSecondaryRoot(this.WorkflowCompensationBehavior, null); // Add the root compensationToken to track all root CA execution order. this.Add(CompensationToken.RootCompensationId, new CompensationTokenData(CompensationToken.RootCompensationId, CompensationToken.RootCompensationId)); this.IsWorkflowCompensationBehaviorScheduled = true; } public long GetNextId() { return ++this.Id; } public void NotifyMessage(NativeActivityContext context, long compensationId, CompensationBookmarkName compensationBookmark) { Bookmark bookmark = FindBookmark(compensationId, compensationBookmark); if (bookmark != null) { context.ResumeBookmark(bookmark, compensationId); } else { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.BookmarkNotRegistered(compensationBookmark))); } } IEnumerable
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FixedSOMPageConstructor.cs
- MappingModelBuildProvider.cs
- PageThemeCodeDomTreeGenerator.cs
- DataRow.cs
- TdsParserStateObject.cs
- PrintControllerWithStatusDialog.cs
- HttpModuleCollection.cs
- MarkupWriter.cs
- ApplicationDirectory.cs
- ImageListStreamer.cs
- QilParameter.cs
- XmlAnyElementAttributes.cs
- ObjectStateEntryDbDataRecord.cs
- SystemResourceKey.cs
- QueryStringParameter.cs
- AQNBuilder.cs
- SerializationTrace.cs
- MultipartIdentifier.cs
- DispatcherFrame.cs
- COMException.cs
- CollectionViewGroupRoot.cs
- SafeFindHandle.cs
- CustomSignedXml.cs
- ParameterElementCollection.cs
- SchemaElementLookUpTable.cs
- UnsafeNativeMethods.cs
- ComponentCollection.cs
- WorkingDirectoryEditor.cs
- DSACryptoServiceProvider.cs
- RecognizerStateChangedEventArgs.cs
- WorkflowQueuingService.cs
- DataObject.cs
- WebServicesSection.cs
- AdornerLayer.cs
- DataGridViewEditingControlShowingEventArgs.cs
- ScrollViewerAutomationPeer.cs
- SafeLibraryHandle.cs
- HyperLink.cs
- LinqDataSourceDisposeEventArgs.cs
- RadioButton.cs
- MinMaxParagraphWidth.cs
- WebPartManagerInternals.cs
- SqlLiftWhereClauses.cs
- BamlTreeUpdater.cs
- UserValidatedEventArgs.cs
- SoapFormatter.cs
- Internal.cs
- TransactionFlowOption.cs
- WsdlServiceChannelBuilder.cs
- SafeCryptoHandles.cs
- MenuItem.cs
- IpcManager.cs
- SqlHelper.cs
- WindowsListViewGroup.cs
- Ops.cs
- FieldTemplateUserControl.cs
- PresentationAppDomainManager.cs
- BackoffTimeoutHelper.cs
- OdbcEnvironmentHandle.cs
- ConfigXmlDocument.cs
- CalculatedColumn.cs
- SHA1Cng.cs
- ValueProviderWrapper.cs
- ToolStripDropDownItem.cs
- FixedPageAutomationPeer.cs
- ScriptServiceAttribute.cs
- CommunicationObjectFaultedException.cs
- HtmlEmptyTagControlBuilder.cs
- ImageCodecInfo.cs
- BlockExpression.cs
- ExpandoClass.cs
- XsdCachingReader.cs
- Win32.cs
- WpfMemberInvoker.cs
- EdmEntityTypeAttribute.cs
- OutputChannelBinder.cs
- SynchronizedInputProviderWrapper.cs
- WebPartDescriptionCollection.cs
- WebPartAddingEventArgs.cs
- Console.cs
- ServiceInstallComponent.cs
- ContentPresenter.cs
- PermissionSetTriple.cs
- Msec.cs
- ObjectStorage.cs
- QueryOutputWriter.cs
- AmbientLight.cs
- DrawingAttributesDefaultValueFactory.cs
- ActiveXContainer.cs
- SchemeSettingElementCollection.cs
- XAMLParseException.cs
- BlockCollection.cs
- WindowCollection.cs
- ObjectHelper.cs
- DataGrid.cs
- LoadMessageLogger.cs
- HttpCapabilitiesBase.cs
- FormViewPagerRow.cs
- FixUp.cs
- HtmlImage.cs