Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / InternalCompensate.cs / 1305376 / InternalCompensate.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Statements { using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Runtime; sealed class InternalCompensate : NativeActivity { public InternalCompensate() : base() { } public InArgumentTarget { get; set; } protected override bool CanInduceIdle { get { return true; } } protected override void CacheMetadata(NativeActivityMetadata metadata) { RuntimeArgument targetArgument = new RuntimeArgument("Target", typeof(CompensationToken), ArgumentDirection.In); metadata.Bind(this.Target, targetArgument); metadata.SetArgumentsCollection(new Collection { targetArgument }); } protected override void Execute(NativeActivityContext context) { CompensationExtension compensationExtension = context.GetExtension (); Fx.Assert(compensationExtension != null, "CompensationExtension must be valid"); CompensationToken compensationToken = Target.Get(context); Fx.Assert(compensationToken != null, "CompensationToken must be valid"); // The compensationToken should be a valid one at this point. Ensure its validated in Compensate activity. CompensationTokenData tokenData = compensationExtension.Get(compensationToken.CompensationId); Fx.Assert(tokenData != null, "The compensationToken should be a valid one at this point. Ensure its validated in Compensate activity."); Fx.Assert(tokenData.BookmarkTable[CompensationBookmarkName.Compensated] == null, "Bookmark should not be already initialized in the bookmark table."); tokenData.BookmarkTable[CompensationBookmarkName.Compensated] = context.CreateBookmark(new BookmarkCallback(OnCompensated)); tokenData.CompensationState = CompensationState.Compensating; compensationExtension.NotifyMessage(context, tokenData.CompensationId, CompensationBookmarkName.OnCompensation); } // Successfully received Compensated response. void OnCompensated(NativeActivityContext context, Bookmark bookmark, object value) { CompensationExtension compensationExtension = context.GetExtension (); Fx.Assert(compensationExtension != null, "CompensationExtension must be valid"); CompensationToken compensationToken = Target.Get(context); Fx.Assert(compensationToken != null, "CompensationToken must be valid"); CompensationTokenData tokenData = compensationExtension.Get(compensationToken.CompensationId); Fx.Assert(tokenData != null, "The compensationToken should be a valid one at this point. Ensure its validated in Compensate activity."); tokenData.CompensationState = CompensationState.Compensated; if(TD.CompensationStateIsEnabled()) { TD.CompensationState(tokenData.DisplayName, tokenData.CompensationState.ToString()); } // Remove the token from the parent! if (tokenData.ParentCompensationId != CompensationToken.RootCompensationId) { CompensationTokenData parentToken = compensationExtension.Get(tokenData.ParentCompensationId); Fx.Assert(parentToken != null, "parentToken must be valid"); parentToken.ExecutionTracker.Remove(tokenData); } else { // remove from workflow root... CompensationTokenData parentToken = compensationExtension.Get(CompensationToken.RootCompensationId); Fx.Assert(parentToken != null, "parentToken must be valid"); parentToken.ExecutionTracker.Remove(tokenData); } tokenData.RemoveBookmark(context, CompensationBookmarkName.Compensated); // Remove the token from the extension... compensationExtension.Remove(compensationToken.CompensationId); } protected override void Cancel(NativeActivityContext context) { // Suppress Cancel } } } // 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
- TransportSecurityBindingElement.cs
- InstanceCreationEditor.cs
- GraphicsContext.cs
- SchemaObjectWriter.cs
- WindowCollection.cs
- SqlUserDefinedAggregateAttribute.cs
- DecimalFormatter.cs
- ToolboxItemFilterAttribute.cs
- PolicyManager.cs
- Transform3DGroup.cs
- FormViewModeEventArgs.cs
- ComponentSerializationService.cs
- Util.cs
- SqlIdentifier.cs
- TableChangeProcessor.cs
- TreeView.cs
- XmlCDATASection.cs
- QuaternionConverter.cs
- PingReply.cs
- RectConverter.cs
- DiagnosticTrace.cs
- BaseTemplateParser.cs
- ResXResourceWriter.cs
- QueryExpr.cs
- ExpressionSelection.cs
- TabPanel.cs
- HighContrastHelper.cs
- EntityException.cs
- RSAProtectedConfigurationProvider.cs
- FileReservationCollection.cs
- SemanticResolver.cs
- ColorAnimation.cs
- ResourceDescriptionAttribute.cs
- Knowncolors.cs
- XmlReflectionMember.cs
- HwndKeyboardInputProvider.cs
- MdImport.cs
- SafeWaitHandle.cs
- OdbcHandle.cs
- SqlUserDefinedTypeAttribute.cs
- LineBreak.cs
- Freezable.cs
- RenderDataDrawingContext.cs
- RelatedView.cs
- ApplicationException.cs
- FileChangesMonitor.cs
- Resources.Designer.cs
- HashAlgorithm.cs
- UInt16.cs
- BinaryCommonClasses.cs
- ControlBuilder.cs
- BindingGroup.cs
- KeyGestureConverter.cs
- GroupDescription.cs
- KerberosReceiverSecurityToken.cs
- ControlPropertyNameConverter.cs
- HtmlLiteralTextAdapter.cs
- RedistVersionInfo.cs
- SwitchLevelAttribute.cs
- AuthorizationRuleCollection.cs
- DataContractSet.cs
- ScriptResourceAttribute.cs
- Permission.cs
- WebPartConnectionsConnectVerb.cs
- DataGridViewRowCollection.cs
- UriWriter.cs
- Point.cs
- SettingsPropertyWrongTypeException.cs
- RegexWriter.cs
- WebBrowserSiteBase.cs
- SEHException.cs
- LoopExpression.cs
- SqlBulkCopyColumnMapping.cs
- MessageSecurityVersion.cs
- IconHelper.cs
- Math.cs
- ErrorFormatter.cs
- WindowsGrip.cs
- TypedReference.cs
- VectorAnimationBase.cs
- SelectionRangeConverter.cs
- WebBrowserSiteBase.cs
- TrustLevel.cs
- XmlSerializationReader.cs
- SQLBytesStorage.cs
- WindowsComboBox.cs
- SchemaTypeEmitter.cs
- SqlDeflator.cs
- DetailsViewDeleteEventArgs.cs
- TypeInitializationException.cs
- IPGlobalProperties.cs
- ScrollEventArgs.cs
- ZipIOCentralDirectoryFileHeader.cs
- InstanceCompleteException.cs
- TraceXPathNavigator.cs
- HttpWrapper.cs
- NameValuePermission.cs
- TypeUnloadedException.cs
- DesignerForm.cs
- TdsParameterSetter.cs