Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Behaviors / Compensation.cs / 1305376 / Compensation.cs
namespace System.Workflow.ComponentModel { using System; using System.Drawing; using System.ComponentModel; using System.Collections; using System.ComponentModel.Design; using System.Workflow.ComponentModel.Design; using System.Workflow.ComponentModel.Compiler; [ToolboxItem(false)] [Designer(typeof(CompensationHandlerActivityDesigner), typeof(IDesigner))] [ToolboxBitmap(typeof(CompensationHandlerActivity), "Resources.Compensation.png")] [ActivityValidator(typeof(CompensationValidator))] [AlternateFlowActivityAttribute] [SRCategory(SR.Standard)] public sealed class CompensationHandlerActivity : CompositeActivity, IActivityEventListener{ public CompensationHandlerActivity() { } public CompensationHandlerActivity(string name) : base(name) { } protected internal override void Initialize(IServiceProvider provider) { if (this.Parent == null) throw new InvalidOperationException(SR.GetString(SR.Error_MustHaveParent)); base.Initialize(provider); } protected internal override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { return SequenceHelper.Execute(this, executionContext); } protected internal override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext) { return SequenceHelper.Cancel(this, executionContext); } void IActivityEventListener .OnEvent(Object sender, ActivityExecutionStatusChangedEventArgs e) { SequenceHelper.OnEvent(this, sender, e); } protected internal override void OnActivityChangeRemove(ActivityExecutionContext executionContext, Activity removedActivity) { SequenceHelper.OnActivityChangeRemove(this, executionContext, removedActivity); } protected internal override void OnWorkflowChangesCompleted(ActivityExecutionContext executionContext) { SequenceHelper.OnWorkflowChangesCompleted(this, executionContext); } } internal sealed class CompensationValidator : CompositeActivityValidator { public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { ValidationErrorCollection validationErrors = base.Validate(manager, obj); CompensationHandlerActivity compensation = obj as CompensationHandlerActivity; if (compensation == null) throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(CompensationHandlerActivity).FullName), "obj"); // check parent must be compensatable if (!(compensation.Parent is ICompensatableActivity)) validationErrors.Add(new ValidationError(SR.GetString(SR.Error_ParentDoesNotSupportCompensation), ErrorNumbers.Error_FaultHandlerActivityParentNotFaultHandlersActivity)); if (compensation.EnabledActivities.Count == 0) validationErrors.Add(new ValidationError(SR.GetString(SR.Warning_EmptyBehaviourActivity, typeof(CompensationHandlerActivity).FullName, compensation.QualifiedName), ErrorNumbers.Warning_EmptyBehaviourActivity, true)); // compensation handlers can not contain fault handlers, compensation handler and cancellation handler else if (((ISupportAlternateFlow)compensation).AlternateFlowActivities.Count > 0) validationErrors.Add(new ValidationError(SR.GetString(SR.Error_ModelingConstructsCanNotContainModelingConstructs), ErrorNumbers.Error_ModelingConstructsCanNotContainModelingConstructs)); return validationErrors; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Workflow.ComponentModel { using System; using System.Drawing; using System.ComponentModel; using System.Collections; using System.ComponentModel.Design; using System.Workflow.ComponentModel.Design; using System.Workflow.ComponentModel.Compiler; [ToolboxItem(false)] [Designer(typeof(CompensationHandlerActivityDesigner), typeof(IDesigner))] [ToolboxBitmap(typeof(CompensationHandlerActivity), "Resources.Compensation.png")] [ActivityValidator(typeof(CompensationValidator))] [AlternateFlowActivityAttribute] [SRCategory(SR.Standard)] public sealed class CompensationHandlerActivity : CompositeActivity, IActivityEventListener { public CompensationHandlerActivity() { } public CompensationHandlerActivity(string name) : base(name) { } protected internal override void Initialize(IServiceProvider provider) { if (this.Parent == null) throw new InvalidOperationException(SR.GetString(SR.Error_MustHaveParent)); base.Initialize(provider); } protected internal override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { return SequenceHelper.Execute(this, executionContext); } protected internal override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext) { return SequenceHelper.Cancel(this, executionContext); } void IActivityEventListener .OnEvent(Object sender, ActivityExecutionStatusChangedEventArgs e) { SequenceHelper.OnEvent(this, sender, e); } protected internal override void OnActivityChangeRemove(ActivityExecutionContext executionContext, Activity removedActivity) { SequenceHelper.OnActivityChangeRemove(this, executionContext, removedActivity); } protected internal override void OnWorkflowChangesCompleted(ActivityExecutionContext executionContext) { SequenceHelper.OnWorkflowChangesCompleted(this, executionContext); } } internal sealed class CompensationValidator : CompositeActivityValidator { public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { ValidationErrorCollection validationErrors = base.Validate(manager, obj); CompensationHandlerActivity compensation = obj as CompensationHandlerActivity; if (compensation == null) throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(CompensationHandlerActivity).FullName), "obj"); // check parent must be compensatable if (!(compensation.Parent is ICompensatableActivity)) validationErrors.Add(new ValidationError(SR.GetString(SR.Error_ParentDoesNotSupportCompensation), ErrorNumbers.Error_FaultHandlerActivityParentNotFaultHandlersActivity)); if (compensation.EnabledActivities.Count == 0) validationErrors.Add(new ValidationError(SR.GetString(SR.Warning_EmptyBehaviourActivity, typeof(CompensationHandlerActivity).FullName, compensation.QualifiedName), ErrorNumbers.Warning_EmptyBehaviourActivity, true)); // compensation handlers can not contain fault handlers, compensation handler and cancellation handler else if (((ISupportAlternateFlow)compensation).AlternateFlowActivities.Count > 0) validationErrors.Add(new ValidationError(SR.GetString(SR.Error_ModelingConstructsCanNotContainModelingConstructs), ErrorNumbers.Error_ModelingConstructsCanNotContainModelingConstructs)); return validationErrors; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FormsIdentity.cs
- Win32.cs
- DispatcherFrame.cs
- CacheDict.cs
- TemplateKey.cs
- AutoResizedEvent.cs
- TrackingStringDictionary.cs
- GeneratedView.cs
- EmptyEnumerable.cs
- BufferedStream2.cs
- SkinBuilder.cs
- TypedElement.cs
- PathSegmentCollection.cs
- wmiprovider.cs
- ScaleTransform.cs
- StateFinalizationActivity.cs
- EntityViewContainer.cs
- safesecurityhelperavalon.cs
- Int16AnimationUsingKeyFrames.cs
- DebuggerAttributes.cs
- StyleCollectionEditor.cs
- ClockController.cs
- activationcontext.cs
- ImageListUtils.cs
- PrintingPermission.cs
- ObjectQuery.cs
- UTF32Encoding.cs
- Ipv6Element.cs
- DataMisalignedException.cs
- TypeListConverter.cs
- HttpException.cs
- COM2FontConverter.cs
- ListView.cs
- PathStreamGeometryContext.cs
- XmlAttributes.cs
- SimpleBitVector32.cs
- RelationshipManager.cs
- ExtensionQuery.cs
- ConsoleTraceListener.cs
- control.ime.cs
- WebPartCancelEventArgs.cs
- PassportAuthenticationModule.cs
- DbDeleteCommandTree.cs
- TypeBrowserDialog.cs
- UrlAuthorizationModule.cs
- SID.cs
- LoginStatusDesigner.cs
- XPathExpr.cs
- DataBinding.cs
- WindowsStartMenu.cs
- ServiceOperationParameter.cs
- TextParagraphCache.cs
- MethodBuilderInstantiation.cs
- ObjectConverter.cs
- LogLogRecord.cs
- TransactedReceiveData.cs
- VerificationAttribute.cs
- ActionFrame.cs
- HttpCapabilitiesBase.cs
- PopupRoot.cs
- OleDbInfoMessageEvent.cs
- IPGlobalProperties.cs
- CheckBox.cs
- _ConnectStream.cs
- StoragePropertyMapping.cs
- InnerItemCollectionView.cs
- TempEnvironment.cs
- RequiredFieldValidator.cs
- MachineSettingsSection.cs
- WebFaultException.cs
- ProviderManager.cs
- XmlDataSourceNodeDescriptor.cs
- SystemMulticastIPAddressInformation.cs
- EntityCommandDefinition.cs
- StrongNameIdentityPermission.cs
- RepeatBehaviorConverter.cs
- StylusPointDescription.cs
- MbpInfo.cs
- Columns.cs
- TreeViewItem.cs
- CachedFontFamily.cs
- TableLayoutColumnStyleCollection.cs
- SmtpException.cs
- SendKeys.cs
- SinglePageViewer.cs
- COM2ExtendedUITypeEditor.cs
- BooleanSwitch.cs
- DataGridCommandEventArgs.cs
- InputBinding.cs
- ValueTypeFixupInfo.cs
- TextChange.cs
- PeerResolver.cs
- basenumberconverter.cs
- sortedlist.cs
- DataServiceQuery.cs
- Attributes.cs
- SingleTagSectionHandler.cs
- XNameConverter.cs
- MenuItemStyleCollectionEditor.cs
- GlobalItem.cs