Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Compiler / Validation / TransactionContextValidator.cs / 1305376 / TransactionContextValidator.cs
namespace System.Workflow.ComponentModel.Compiler { using System; using System.Reflection; using System.Globalization; using System.Collections.Generic; using System.Workflow.ComponentModel.Design; internal sealed class TransactionContextValidator : Validator { #region Validate Method public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { ValidationErrorCollection validationErrors = base.Validate(manager, obj); Activity activity = obj as Activity; if (activity == null) throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(Activity).FullName), "obj"); WorkflowTransactionOptions atomicTransaction = TransactedContextFilter.GetTransactionOptions(activity); if (atomicTransaction != null) { // Atomic scopes can't have exception handlers. CompositeActivity exceptionHandlers = FaultAndCancellationHandlingFilter.GetFaultHandlers(activity); if (exceptionHandlers != null) { ValidationError error = new ValidationError(SR.GetString(SR.Error_AtomicScopeWithFaultHandlersActivityDecl, activity.Name), ErrorNumbers.Error_AtomicScopeWithFaultHandlersActivityDecl); validationErrors.Add(error); } // Atomic scopes can't have cancel handlers. Activity cancellationHandler = FaultAndCancellationHandlingFilter.GetCancellationHandler(activity); if (cancellationHandler != null) { ValidationError error = new ValidationError(SR.GetString(SR.Error_AtomicScopeWithCancellationHandlerActivity, activity.Name), ErrorNumbers.Error_AtomicScopeWithCancellationHandlerActivity); validationErrors.Add(error); } // check that this transaction scope is not nested inside another transaction scope Activity parent = activity.Parent; while (parent != null) { if (parent.SupportsTransaction) { validationErrors.Add(new ValidationError(SR.GetString(SR.Error_AtomicScopeNestedInNonLRT), ErrorNumbers.Error_AtomicScopeNestedInNonLRT)); break; } parent = parent.Parent; } // check that an activity with PersistOnClose/SupportsTransaction/ICompensatableActivity attribute is not nested inside the transaction scope QueuenestedEnabledActivities = new Queue (Helpers.GetAllEnabledActivities((CompositeActivity)activity)); while (nestedEnabledActivities.Count > 0) { Activity nestedEnabledActivity = nestedEnabledActivities.Dequeue(); if (nestedEnabledActivity.PersistOnClose) { validationErrors.Add(new ValidationError(SR.GetString(SR.Error_LRTScopeNestedInNonLRT), ErrorNumbers.Error_LRTScopeNestedInNonLRT)); break; } if (nestedEnabledActivity is ICompensatableActivity) { validationErrors.Add(new ValidationError(SR.GetString(SR.Error_NestedCompensatableActivity, nestedEnabledActivity.QualifiedName), ErrorNumbers.Error_NestedCompensatableActivity)); break; } if (nestedEnabledActivity is CompositeActivity) { foreach (Activity nestedEnabledActivity2 in Helpers.GetAllEnabledActivities((CompositeActivity)nestedEnabledActivity)) nestedEnabledActivities.Enqueue(nestedEnabledActivity2); } } // check timeout property if (atomicTransaction.TimeoutDuration.Ticks < 0) { ValidationError timeoutError = new ValidationError(SR.GetString(SR.Error_NegativeValue, new object[] { atomicTransaction.TimeoutDuration.ToString(), "TimeoutDuration" }), ErrorNumbers.Error_NegativeValue); timeoutError.PropertyName = "TimeoutDuration"; validationErrors.Add(timeoutError); } } return validationErrors; } public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action) { if (activity == null) throw new ArgumentNullException("activity"); if (action == null) throw new ArgumentNullException("action"); AddedActivityAction addedAction = action as AddedActivityAction; if (addedAction != null) { //Check existence of nested PersistOnClose/ICompensatable/SupportsTransaction nested anywhere //in the added activity branch System.Collections.Generic.Queue childrenQueue = new System.Collections.Generic.Queue (); childrenQueue.Enqueue(addedAction.AddedActivity); while (childrenQueue.Count != 0) { Activity childActivity = childrenQueue.Dequeue(); if (childActivity.SupportsTransaction) return new ValidationError(SR.GetString(SR.Error_AtomicScopeNestedInNonLRT), ErrorNumbers.Error_AtomicScopeNestedInNonLRT); if (childActivity.PersistOnClose) return new ValidationError(SR.GetString(SR.Error_NestedPersistOnClose, activity.QualifiedName), ErrorNumbers.Error_NestedPersistOnClose); if (childActivity is ICompensatableActivity) return new ValidationError(SR.GetString(SR.Error_NestedCompensatableActivity, activity.QualifiedName), ErrorNumbers.Error_NestedCompensatableActivity); CompositeActivity compositeActivity = childActivity as CompositeActivity; if (compositeActivity != null) { foreach (Activity grandChild in compositeActivity.EnabledActivities) { childrenQueue.Enqueue(grandChild); } } } } return base.ValidateActivityChange(activity, action); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Workflow.ComponentModel.Compiler { using System; using System.Reflection; using System.Globalization; using System.Collections.Generic; using System.Workflow.ComponentModel.Design; internal sealed class TransactionContextValidator : Validator { #region Validate Method public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { ValidationErrorCollection validationErrors = base.Validate(manager, obj); Activity activity = obj as Activity; if (activity == null) throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(Activity).FullName), "obj"); WorkflowTransactionOptions atomicTransaction = TransactedContextFilter.GetTransactionOptions(activity); if (atomicTransaction != null) { // Atomic scopes can't have exception handlers. CompositeActivity exceptionHandlers = FaultAndCancellationHandlingFilter.GetFaultHandlers(activity); if (exceptionHandlers != null) { ValidationError error = new ValidationError(SR.GetString(SR.Error_AtomicScopeWithFaultHandlersActivityDecl, activity.Name), ErrorNumbers.Error_AtomicScopeWithFaultHandlersActivityDecl); validationErrors.Add(error); } // Atomic scopes can't have cancel handlers. Activity cancellationHandler = FaultAndCancellationHandlingFilter.GetCancellationHandler(activity); if (cancellationHandler != null) { ValidationError error = new ValidationError(SR.GetString(SR.Error_AtomicScopeWithCancellationHandlerActivity, activity.Name), ErrorNumbers.Error_AtomicScopeWithCancellationHandlerActivity); validationErrors.Add(error); } // check that this transaction scope is not nested inside another transaction scope Activity parent = activity.Parent; while (parent != null) { if (parent.SupportsTransaction) { validationErrors.Add(new ValidationError(SR.GetString(SR.Error_AtomicScopeNestedInNonLRT), ErrorNumbers.Error_AtomicScopeNestedInNonLRT)); break; } parent = parent.Parent; } // check that an activity with PersistOnClose/SupportsTransaction/ICompensatableActivity attribute is not nested inside the transaction scope Queue nestedEnabledActivities = new Queue (Helpers.GetAllEnabledActivities((CompositeActivity)activity)); while (nestedEnabledActivities.Count > 0) { Activity nestedEnabledActivity = nestedEnabledActivities.Dequeue(); if (nestedEnabledActivity.PersistOnClose) { validationErrors.Add(new ValidationError(SR.GetString(SR.Error_LRTScopeNestedInNonLRT), ErrorNumbers.Error_LRTScopeNestedInNonLRT)); break; } if (nestedEnabledActivity is ICompensatableActivity) { validationErrors.Add(new ValidationError(SR.GetString(SR.Error_NestedCompensatableActivity, nestedEnabledActivity.QualifiedName), ErrorNumbers.Error_NestedCompensatableActivity)); break; } if (nestedEnabledActivity is CompositeActivity) { foreach (Activity nestedEnabledActivity2 in Helpers.GetAllEnabledActivities((CompositeActivity)nestedEnabledActivity)) nestedEnabledActivities.Enqueue(nestedEnabledActivity2); } } // check timeout property if (atomicTransaction.TimeoutDuration.Ticks < 0) { ValidationError timeoutError = new ValidationError(SR.GetString(SR.Error_NegativeValue, new object[] { atomicTransaction.TimeoutDuration.ToString(), "TimeoutDuration" }), ErrorNumbers.Error_NegativeValue); timeoutError.PropertyName = "TimeoutDuration"; validationErrors.Add(timeoutError); } } return validationErrors; } public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action) { if (activity == null) throw new ArgumentNullException("activity"); if (action == null) throw new ArgumentNullException("action"); AddedActivityAction addedAction = action as AddedActivityAction; if (addedAction != null) { //Check existence of nested PersistOnClose/ICompensatable/SupportsTransaction nested anywhere //in the added activity branch System.Collections.Generic.Queue childrenQueue = new System.Collections.Generic.Queue (); childrenQueue.Enqueue(addedAction.AddedActivity); while (childrenQueue.Count != 0) { Activity childActivity = childrenQueue.Dequeue(); if (childActivity.SupportsTransaction) return new ValidationError(SR.GetString(SR.Error_AtomicScopeNestedInNonLRT), ErrorNumbers.Error_AtomicScopeNestedInNonLRT); if (childActivity.PersistOnClose) return new ValidationError(SR.GetString(SR.Error_NestedPersistOnClose, activity.QualifiedName), ErrorNumbers.Error_NestedPersistOnClose); if (childActivity is ICompensatableActivity) return new ValidationError(SR.GetString(SR.Error_NestedCompensatableActivity, activity.QualifiedName), ErrorNumbers.Error_NestedCompensatableActivity); CompositeActivity compositeActivity = childActivity as CompositeActivity; if (compositeActivity != null) { foreach (Activity grandChild in compositeActivity.EnabledActivities) { childrenQueue.Enqueue(grandChild); } } } } return base.ValidateActivityChange(activity, action); } #endregion } } // 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
- PriorityRange.cs
- CookieParameter.cs
- Form.cs
- DockAndAnchorLayout.cs
- ReadOnlyDataSourceView.cs
- WebConfigurationHostFileChange.cs
- URLMembershipCondition.cs
- WindowsComboBox.cs
- TemplatedMailWebEventProvider.cs
- Int32RectConverter.cs
- ResizeGrip.cs
- LogicalMethodInfo.cs
- ExpandedWrapper.cs
- AsymmetricKeyExchangeDeformatter.cs
- SqlClientWrapperSmiStreamChars.cs
- ShaderEffect.cs
- SmiGettersStream.cs
- EndpointDispatcherTable.cs
- MeshGeometry3D.cs
- SqlUserDefinedAggregateAttribute.cs
- KeyFrames.cs
- RequestCache.cs
- MSAANativeProvider.cs
- UInt16Storage.cs
- ClientTarget.cs
- ThumbButtonInfo.cs
- UnmanagedMemoryStream.cs
- EdmItemCollection.OcAssemblyCache.cs
- QueueProcessor.cs
- RoutingTable.cs
- WebConvert.cs
- ImageMapEventArgs.cs
- UnwrappedTypesXmlSerializerManager.cs
- VisualBasicExpressionConverter.cs
- HMACSHA512.cs
- OrderedEnumerableRowCollection.cs
- HttpListener.cs
- EncoderParameter.cs
- RemoteCryptoRsaServiceProvider.cs
- ZipIOExtraFieldPaddingElement.cs
- GlobalizationSection.cs
- BrowserDefinition.cs
- XmlComment.cs
- BamlBinaryReader.cs
- ClientFormsAuthenticationMembershipProvider.cs
- XsltQilFactory.cs
- TextProperties.cs
- TextTreeRootTextBlock.cs
- DataTableReaderListener.cs
- InputLanguageEventArgs.cs
- BuildDependencySet.cs
- Utility.cs
- OptimisticConcurrencyException.cs
- PasswordPropertyTextAttribute.cs
- AccessibleObject.cs
- RestHandler.cs
- DesignerActionGlyph.cs
- SamlSerializer.cs
- ChtmlTextBoxAdapter.cs
- AspNetHostingPermission.cs
- ToolStripItemCollection.cs
- Clipboard.cs
- SpellerError.cs
- DetailsViewActionList.cs
- TaskHelper.cs
- StorageMappingItemLoader.cs
- MimeTextImporter.cs
- ProfessionalColors.cs
- grammarelement.cs
- WebContext.cs
- BindingExpressionBase.cs
- CookieProtection.cs
- UnsafeNativeMethods.cs
- FormViewInsertedEventArgs.cs
- ReferencedType.cs
- ProcessThread.cs
- TextEvent.cs
- WebPartDisplayModeEventArgs.cs
- SymmetricAlgorithm.cs
- ItemsPanelTemplate.cs
- TemplatePropertyEntry.cs
- InputMethodStateTypeInfo.cs
- IOException.cs
- IndexerHelper.cs
- OverrideMode.cs
- ColumnHeader.cs
- OuterGlowBitmapEffect.cs
- ChangePassword.cs
- SByteStorage.cs
- Pair.cs
- ColorInterpolationModeValidation.cs
- CodeAttributeDeclaration.cs
- HttpFileCollectionBase.cs
- WindowsListViewItem.cs
- FormsAuthenticationEventArgs.cs
- BitmapCodecInfo.cs
- XmlTextEncoder.cs
- DivideByZeroException.cs
- AbandonedMutexException.cs
- TcpAppDomainProtocolHandler.cs