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
- WindowsAuthenticationModule.cs
- PageBuildProvider.cs
- ExpandSegment.cs
- ProfessionalColorTable.cs
- SelfSignedCertificate.cs
- AttributeTable.cs
- IntranetCredentialPolicy.cs
- XmlCollation.cs
- Rule.cs
- QueryReaderSettings.cs
- InputEventArgs.cs
- HotSpot.cs
- TraceSection.cs
- ProjectionCamera.cs
- MetadataException.cs
- TreeViewHitTestInfo.cs
- TimeManager.cs
- SkewTransform.cs
- ListItemViewAttribute.cs
- ProgressBarHighlightConverter.cs
- StructuredType.cs
- BindValidationContext.cs
- EndOfStreamException.cs
- BitConverter.cs
- CustomAttributeSerializer.cs
- TransportManager.cs
- TextParaClient.cs
- FileSystemInfo.cs
- GridViewEditEventArgs.cs
- Int32Rect.cs
- FacetDescriptionElement.cs
- Schema.cs
- SmtpFailedRecipientException.cs
- FormViewDeletedEventArgs.cs
- AsyncOperationManager.cs
- CallContext.cs
- HtmlEmptyTagControlBuilder.cs
- EncryptedData.cs
- CompositeCollection.cs
- StatusBarItemAutomationPeer.cs
- MissingManifestResourceException.cs
- XmlChildEnumerator.cs
- ListView.cs
- DATA_BLOB.cs
- CursorConverter.cs
- CounterSampleCalculator.cs
- CngProvider.cs
- _NestedMultipleAsyncResult.cs
- altserialization.cs
- ReservationCollection.cs
- ProcessThreadDesigner.cs
- ConnectionInterfaceCollection.cs
- AuthorizationSection.cs
- ExclusiveTcpListener.cs
- WebBrowserNavigatedEventHandler.cs
- DataPagerFieldCommandEventArgs.cs
- SamlAuthorityBinding.cs
- RuntimeConfigurationRecord.cs
- COSERVERINFO.cs
- WebZone.cs
- UndoManager.cs
- Pens.cs
- QilFactory.cs
- ExtendedProperty.cs
- EndpointConfigContainer.cs
- RunInstallerAttribute.cs
- Image.cs
- OdbcConnection.cs
- SystemIPGlobalStatistics.cs
- ToolStripPanelSelectionBehavior.cs
- ProfilePropertyMetadata.cs
- BitmapInitialize.cs
- BoundsDrawingContextWalker.cs
- SqlRemoveConstantOrderBy.cs
- CopyOnWriteList.cs
- CompatibleIComparer.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- EventManager.cs
- RelationalExpressions.cs
- RequestDescription.cs
- Stack.cs
- CommandHelper.cs
- AssemblyName.cs
- WindowsMenu.cs
- WebPartManagerInternals.cs
- InstanceKeyCollisionException.cs
- ImageMetadata.cs
- UidManager.cs
- InvalidateEvent.cs
- NonSerializedAttribute.cs
- itemelement.cs
- RuleRef.cs
- FormViewPagerRow.cs
- FixedSchema.cs
- ControllableStoryboardAction.cs
- ButtonAutomationPeer.cs
- ContentPathSegment.cs
- ArgIterator.cs
- Point3DCollectionValueSerializer.cs
- BevelBitmapEffect.cs