Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / EventDriven.cs / 1305376 / EventDriven.cs
namespace System.Workflow.Activities { #region Imports using System; using System.Text; using System.Reflection; using System.Collections; using System.Collections.Generic; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Workflow.ComponentModel.Compiler; using System.Collections.ObjectModel; using System.Workflow.Activities.Common; #endregion [SRDescription(SR.EventDrivenActivityDescription)] [Designer(typeof(EventDrivenDesigner), typeof(IDesigner))] [ToolboxItem(typeof(ActivityToolboxItem))] [ToolboxBitmap(typeof(EventDrivenActivity), "Resources.EventDriven.png")] [ActivityValidator(typeof(EventDrivenValidator))] [SRCategory(SR.Standard)] public sealed class EventDrivenActivity : SequenceActivity { public EventDrivenActivity() { } public EventDrivenActivity(string name) : base(name) { } [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public IEventActivity EventActivity { get { ReadOnlyCollectionenabledActivities = this.EnabledActivities; if (enabledActivities.Count == 0) return null; else return enabledActivities[0] as IEventActivity; } } } internal sealed class EventDrivenValidator : CompositeActivityValidator { public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { ValidationErrorCollection validationErrors = base.Validate(manager, obj); EventDrivenActivity eventDriven = obj as EventDrivenActivity; if (eventDriven == null) throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(EventDrivenActivity).FullName), "obj"); // check parent if (!(eventDriven.Parent is ListenActivity) && !(eventDriven.Parent is EventHandlersActivity) && !(eventDriven.Parent is StateActivity) ) validationErrors.Add(new ValidationError(SR.GetError_EventDrivenParentNotListen(), ErrorNumbers.Error_EventDrivenParentNotListen)); // validate Event property string message = string.Empty; int errorNumber = -1; Activity firstActivity = (eventDriven.EnabledActivities.Count > 0) ? eventDriven.EnabledActivities[0] : null; if (firstActivity == null) { message = SR.GetString(SR.Error_EventDrivenNoFirstActivity); errorNumber = ErrorNumbers.Error_EventDrivenNoFirstActivity; } else if (!(firstActivity is IEventActivity)) { message = SR.GetError_EventDrivenInvalidFirstActivity(); errorNumber = ErrorNumbers.Error_EventDrivenInvalidFirstActivity; } if (message.Length > 0) validationErrors.Add(new ValidationError(message, errorNumber)); return validationErrors; } public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action) { if (activity == null) throw new ArgumentNullException("activity"); if (action == null) throw new ArgumentNullException("action"); RemovedActivityAction removedAction = action as RemovedActivityAction; if (removedAction != null && removedAction.RemovedActivityIndex == 0) { return new ValidationError(SR.GetString(SR.Error_EventActivityIsImmutable), ErrorNumbers.Error_DynamicActivity, false); } else { AddedActivityAction addedAction = action as AddedActivityAction; if (addedAction != null && addedAction.Index == 0) return new ValidationError(SR.GetString(SR.Error_EventActivityIsImmutable), ErrorNumbers.Error_DynamicActivity, false); } return base.ValidateActivityChange(activity, action); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Workflow.Activities { #region Imports using System; using System.Text; using System.Reflection; using System.Collections; using System.Collections.Generic; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Workflow.ComponentModel.Compiler; using System.Collections.ObjectModel; using System.Workflow.Activities.Common; #endregion [SRDescription(SR.EventDrivenActivityDescription)] [Designer(typeof(EventDrivenDesigner), typeof(IDesigner))] [ToolboxItem(typeof(ActivityToolboxItem))] [ToolboxBitmap(typeof(EventDrivenActivity), "Resources.EventDriven.png")] [ActivityValidator(typeof(EventDrivenValidator))] [SRCategory(SR.Standard)] public sealed class EventDrivenActivity : SequenceActivity { public EventDrivenActivity() { } public EventDrivenActivity(string name) : base(name) { } [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public IEventActivity EventActivity { get { ReadOnlyCollection enabledActivities = this.EnabledActivities; if (enabledActivities.Count == 0) return null; else return enabledActivities[0] as IEventActivity; } } } internal sealed class EventDrivenValidator : CompositeActivityValidator { public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { ValidationErrorCollection validationErrors = base.Validate(manager, obj); EventDrivenActivity eventDriven = obj as EventDrivenActivity; if (eventDriven == null) throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(EventDrivenActivity).FullName), "obj"); // check parent if (!(eventDriven.Parent is ListenActivity) && !(eventDriven.Parent is EventHandlersActivity) && !(eventDriven.Parent is StateActivity) ) validationErrors.Add(new ValidationError(SR.GetError_EventDrivenParentNotListen(), ErrorNumbers.Error_EventDrivenParentNotListen)); // validate Event property string message = string.Empty; int errorNumber = -1; Activity firstActivity = (eventDriven.EnabledActivities.Count > 0) ? eventDriven.EnabledActivities[0] : null; if (firstActivity == null) { message = SR.GetString(SR.Error_EventDrivenNoFirstActivity); errorNumber = ErrorNumbers.Error_EventDrivenNoFirstActivity; } else if (!(firstActivity is IEventActivity)) { message = SR.GetError_EventDrivenInvalidFirstActivity(); errorNumber = ErrorNumbers.Error_EventDrivenInvalidFirstActivity; } if (message.Length > 0) validationErrors.Add(new ValidationError(message, errorNumber)); return validationErrors; } public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action) { if (activity == null) throw new ArgumentNullException("activity"); if (action == null) throw new ArgumentNullException("action"); RemovedActivityAction removedAction = action as RemovedActivityAction; if (removedAction != null && removedAction.RemovedActivityIndex == 0) { return new ValidationError(SR.GetString(SR.Error_EventActivityIsImmutable), ErrorNumbers.Error_DynamicActivity, false); } else { AddedActivityAction addedAction = action as AddedActivityAction; if (addedAction != null && addedAction.Index == 0) return new ValidationError(SR.GetString(SR.Error_EventActivityIsImmutable), ErrorNumbers.Error_DynamicActivity, false); } return base.ValidateActivityChange(activity, action); } } } // 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
- TcpClientCredentialType.cs
- DocumentPageViewAutomationPeer.cs
- TraceSection.cs
- SelectedDatesCollection.cs
- EndPoint.cs
- XmlValidatingReaderImpl.cs
- WsdlBuildProvider.cs
- ImageAnimator.cs
- propertytag.cs
- TakeQueryOptionExpression.cs
- ClipboardProcessor.cs
- DatasetMethodGenerator.cs
- HostingEnvironmentException.cs
- ReferenceTypeElement.cs
- FixedSOMPage.cs
- EntryPointNotFoundException.cs
- StringConcat.cs
- UndoManager.cs
- IPEndPointCollection.cs
- Object.cs
- XmlParserContext.cs
- ValidatorCollection.cs
- CompilerGeneratedAttribute.cs
- MethodRental.cs
- DefinitionBase.cs
- Speller.cs
- TextBox.cs
- SchemaCollectionPreprocessor.cs
- TextEffect.cs
- TypeDelegator.cs
- DocumentSignatureManager.cs
- SingleKeyFrameCollection.cs
- CodeMemberEvent.cs
- RegularExpressionValidator.cs
- TemplatePagerField.cs
- WebHttpDispatchOperationSelector.cs
- MetabaseReader.cs
- DocumentScope.cs
- PerfCounters.cs
- CreateParams.cs
- DriveInfo.cs
- TypeExtensionConverter.cs
- ThousandthOfEmRealPoints.cs
- ToolStripHighContrastRenderer.cs
- ContextProperty.cs
- HtmlTable.cs
- RelatedEnd.cs
- SqlUserDefinedAggregateAttribute.cs
- NativeMethods.cs
- ToolStripContainerDesigner.cs
- OrCondition.cs
- HostedElements.cs
- ViewValidator.cs
- TextBoxView.cs
- DeferredElementTreeState.cs
- PresentationTraceSources.cs
- GlyphInfoList.cs
- SBCSCodePageEncoding.cs
- UriWriter.cs
- TabletDeviceInfo.cs
- FileDialogCustomPlace.cs
- PackWebResponse.cs
- TdsRecordBufferSetter.cs
- WindowsPrincipal.cs
- XmlBaseWriter.cs
- AddressAlreadyInUseException.cs
- ToggleProviderWrapper.cs
- QueryLifecycle.cs
- TypeConverterHelper.cs
- DataChangedEventManager.cs
- ClientSession.cs
- DataRelation.cs
- IdentityModelStringsVersion1.cs
- LongValidator.cs
- WebHttpBindingCollectionElement.cs
- MappingModelBuildProvider.cs
- CodeIterationStatement.cs
- PointLightBase.cs
- RestHandler.cs
- ImageMapEventArgs.cs
- VariableAction.cs
- TrackingStringDictionary.cs
- ImageMetadata.cs
- PlatformNotSupportedException.cs
- XmlSecureResolver.cs
- CopyAction.cs
- _ProxyRegBlob.cs
- TransformationRules.cs
- SecurityDocument.cs
- XmlElementList.cs
- LineGeometry.cs
- SqlProviderManifest.cs
- NumericUpDownAccelerationCollection.cs
- DocumentXPathNavigator.cs
- ContentPlaceHolderDesigner.cs
- NegotiateStream.cs
- SqlNamer.cs
- RectKeyFrameCollection.cs
- _KerberosClient.cs
- DesignTimeType.cs