Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / CodeExpressionRuleDeclaration.cs / 1305376 / CodeExpressionRuleDeclaration.cs
namespace System.Workflow.Activities { using System; using System.Collections; using System.Collections.Generic; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Reflection; using System.Workflow.ComponentModel; using System.Workflow.Runtime; using System.Workflow.ComponentModel.Compiler; using System.Workflow.ComponentModel.Serialization; using System.Workflow.Runtime.DebugEngine; [ToolboxItem(false)] [ActivityValidator(typeof(CodeConditionValidator))] [SRDisplayName(SR.CodeConditionDisplayName)] public class CodeCondition : ActivityCondition { public static readonly DependencyProperty ConditionEvent = DependencyProperty.Register("Condition", typeof(EventHandler), typeof(CodeCondition)); [SRDescription(SR.ExpressionDescr)] [SRCategory(SR.Handlers)] [MergableProperty(false)] public event EventHandler Condition { add { base.AddHandler(ConditionEvent, value); } remove { base.RemoveHandler(ConditionEvent, value); } } #region Bind resolution Support protected override object GetBoundValue(ActivityBind bind, Type targetType) { if (bind == null) throw new ArgumentNullException("bind"); if (targetType == null) throw new ArgumentNullException("targetType"); object returnVal = bind; Activity activity = this.ParentDependencyObject as Activity; if (activity != null) returnVal = bind.GetRuntimeValue(activity, targetType); return returnVal; } #endregion public override bool Evaluate(Activity ownerActivity, IServiceProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); ConditionalEventArgs eventArgs = new ConditionalEventArgs(); EventHandler [] eventHandlers = base.GetInvocationList >(CodeCondition.ConditionEvent); IWorkflowDebuggerService workflowDebuggerService = provider.GetService(typeof(IWorkflowDebuggerService)) as IWorkflowDebuggerService; if (eventHandlers != null) { foreach (EventHandler eventHandler in eventHandlers) { if (workflowDebuggerService != null) workflowDebuggerService.NotifyHandlerInvoking(eventHandler); eventHandler(ownerActivity, eventArgs); if (workflowDebuggerService != null) workflowDebuggerService.NotifyHandlerInvoked(); } } return eventArgs.Result; } private class CodeConditionValidator : ConditionValidator { public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { ValidationErrorCollection errors = new ValidationErrorCollection(); errors.AddRange(base.Validate(manager, obj)); CodeCondition codeCondition = obj as CodeCondition; if (codeCondition != null) { if (codeCondition.GetInvocationList >(CodeCondition.ConditionEvent).Length == 0 && codeCondition.GetBinding(CodeCondition.ConditionEvent) == null) { Hashtable hashtable = codeCondition.GetValue(WorkflowMarkupSerializer.EventsProperty) as Hashtable; if (hashtable == null || hashtable["Condition"] == null) errors.Add(ValidationError.GetNotSetValidationError(GetFullPropertyName(manager) + ".Condition")); } } return errors; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Workflow.Activities { using System; using System.Collections; using System.Collections.Generic; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Reflection; using System.Workflow.ComponentModel; using System.Workflow.Runtime; using System.Workflow.ComponentModel.Compiler; using System.Workflow.ComponentModel.Serialization; using System.Workflow.Runtime.DebugEngine; [ToolboxItem(false)] [ActivityValidator(typeof(CodeConditionValidator))] [SRDisplayName(SR.CodeConditionDisplayName)] public class CodeCondition : ActivityCondition { public static readonly DependencyProperty ConditionEvent = DependencyProperty.Register("Condition", typeof(EventHandler ), typeof(CodeCondition)); [SRDescription(SR.ExpressionDescr)] [SRCategory(SR.Handlers)] [MergableProperty(false)] public event EventHandler Condition { add { base.AddHandler(ConditionEvent, value); } remove { base.RemoveHandler(ConditionEvent, value); } } #region Bind resolution Support protected override object GetBoundValue(ActivityBind bind, Type targetType) { if (bind == null) throw new ArgumentNullException("bind"); if (targetType == null) throw new ArgumentNullException("targetType"); object returnVal = bind; Activity activity = this.ParentDependencyObject as Activity; if (activity != null) returnVal = bind.GetRuntimeValue(activity, targetType); return returnVal; } #endregion public override bool Evaluate(Activity ownerActivity, IServiceProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); ConditionalEventArgs eventArgs = new ConditionalEventArgs(); EventHandler [] eventHandlers = base.GetInvocationList >(CodeCondition.ConditionEvent); IWorkflowDebuggerService workflowDebuggerService = provider.GetService(typeof(IWorkflowDebuggerService)) as IWorkflowDebuggerService; if (eventHandlers != null) { foreach (EventHandler eventHandler in eventHandlers) { if (workflowDebuggerService != null) workflowDebuggerService.NotifyHandlerInvoking(eventHandler); eventHandler(ownerActivity, eventArgs); if (workflowDebuggerService != null) workflowDebuggerService.NotifyHandlerInvoked(); } } return eventArgs.Result; } private class CodeConditionValidator : ConditionValidator { public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { ValidationErrorCollection errors = new ValidationErrorCollection(); errors.AddRange(base.Validate(manager, obj)); CodeCondition codeCondition = obj as CodeCondition; if (codeCondition != null) { if (codeCondition.GetInvocationList >(CodeCondition.ConditionEvent).Length == 0 && codeCondition.GetBinding(CodeCondition.ConditionEvent) == null) { Hashtable hashtable = codeCondition.GetValue(WorkflowMarkupSerializer.EventsProperty) as Hashtable; if (hashtable == null || hashtable["Condition"] == null) errors.Add(ValidationError.GetNotSetValidationError(GetFullPropertyName(manager) + ".Condition")); } } return errors; } } } } // 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
- TaiwanLunisolarCalendar.cs
- Pen.cs
- PropertyFilterAttribute.cs
- FocusTracker.cs
- ChangePassword.cs
- ActivationServices.cs
- CodeCompiler.cs
- XPathDescendantIterator.cs
- ProtocolInformationWriter.cs
- StdValidatorsAndConverters.cs
- XamlFigureLengthSerializer.cs
- CompositeTypefaceMetrics.cs
- coordinator.cs
- AttachmentService.cs
- FixedSOMTable.cs
- SoapUnknownHeader.cs
- DataControlField.cs
- ListItem.cs
- ISFTagAndGuidCache.cs
- ForeignKeyConstraint.cs
- PropertySegmentSerializer.cs
- CodeAccessPermission.cs
- CodeNamespaceCollection.cs
- EncoderNLS.cs
- GeneralTransform3DTo2DTo3D.cs
- DeobfuscatingStream.cs
- TypeToken.cs
- XmlDataSourceNodeDescriptor.cs
- XmlDocumentFragment.cs
- XPathSelectionIterator.cs
- DataViewManagerListItemTypeDescriptor.cs
- BindableTemplateBuilder.cs
- XmlRawWriter.cs
- SerialReceived.cs
- XmlSecureResolver.cs
- DrawingVisualDrawingContext.cs
- RichTextBoxConstants.cs
- SubpageParaClient.cs
- UIElementAutomationPeer.cs
- ControlCollection.cs
- MailBnfHelper.cs
- Oid.cs
- IncrementalHitTester.cs
- PerformanceCounterLib.cs
- SrgsToken.cs
- AnnotationHighlightLayer.cs
- BuildDependencySet.cs
- AuthorizationRule.cs
- ScaleTransform.cs
- backend.cs
- FillRuleValidation.cs
- ParameterRetriever.cs
- XPathNodeInfoAtom.cs
- ColumnWidthChangedEvent.cs
- ListParaClient.cs
- StateBag.cs
- Msec.cs
- VarRemapper.cs
- ProvidePropertyAttribute.cs
- WizardForm.cs
- SyndicationFeedFormatter.cs
- ConfigurationErrorsException.cs
- EmbeddedObject.cs
- ImageDrawing.cs
- XmlLanguage.cs
- ResourceManager.cs
- SqlTypesSchemaImporter.cs
- DateTimeStorage.cs
- MessageHeaderDescriptionCollection.cs
- RoleServiceManager.cs
- SafeProcessHandle.cs
- Base64Stream.cs
- RelationshipType.cs
- _ListenerRequestStream.cs
- SystemUnicastIPAddressInformation.cs
- activationcontext.cs
- Activity.cs
- HtmlSelect.cs
- ObjectDisposedException.cs
- NullRuntimeConfig.cs
- StringValueSerializer.cs
- ArraySegment.cs
- OleDbInfoMessageEvent.cs
- IResourceProvider.cs
- Matrix3DValueSerializer.cs
- PagedDataSource.cs
- DataObjectAttribute.cs
- _ListenerResponseStream.cs
- SortedSet.cs
- BaseParser.cs
- EntityViewGenerator.cs
- FormViewDeleteEventArgs.cs
- ClientFormsAuthenticationCredentials.cs
- SafeSecurityHandles.cs
- WebEventTraceProvider.cs
- counter.cs
- SapiInterop.cs
- VerificationAttribute.cs
- XmlStringTable.cs
- ProcessInputEventArgs.cs