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
- ControlPropertyNameConverter.cs
- HtmlShimManager.cs
- CursorInteropHelper.cs
- HttpClientCertificate.cs
- TypedOperationInfo.cs
- DesignTimeTemplateParser.cs
- RelatedView.cs
- XsdBuilder.cs
- SlotInfo.cs
- TableItemStyle.cs
- HierarchicalDataBoundControl.cs
- NonDualMessageSecurityOverHttp.cs
- NameValueFileSectionHandler.cs
- SqlServer2KCompatibilityCheck.cs
- IntPtr.cs
- PropertyNames.cs
- DbConnectionHelper.cs
- RegexCharClass.cs
- XmlSchemaDocumentation.cs
- XPathPatternParser.cs
- PropertyMap.cs
- TransformCollection.cs
- ButtonRenderer.cs
- DragStartedEventArgs.cs
- MultiBindingExpression.cs
- IconHelper.cs
- Matrix3DStack.cs
- TableSectionStyle.cs
- CharStorage.cs
- SaveFileDialog.cs
- MarkedHighlightComponent.cs
- WebPartHeaderCloseVerb.cs
- SHA512.cs
- SizeIndependentAnimationStorage.cs
- TileBrush.cs
- FixUpCollection.cs
- storepermission.cs
- EncoderFallback.cs
- ADConnectionHelper.cs
- TypeDescriptor.cs
- CommonObjectSecurity.cs
- DisposableCollectionWrapper.cs
- DataGridView.cs
- PrintDialog.cs
- RegistryConfigurationProvider.cs
- TogglePatternIdentifiers.cs
- TextTreeTextElementNode.cs
- RSAProtectedConfigurationProvider.cs
- RegexCapture.cs
- AudioBase.cs
- BooleanFunctions.cs
- BuildProvider.cs
- TrustSection.cs
- SoapElementAttribute.cs
- DbConnectionPoolCounters.cs
- ScriptMethodAttribute.cs
- X509CertificateValidator.cs
- TypeExtension.cs
- ProjectionPathSegment.cs
- Rotation3D.cs
- FusionWrap.cs
- DbProviderServices.cs
- OptimizerPatterns.cs
- TransformerTypeCollection.cs
- DynamicValueConverter.cs
- GridLength.cs
- sqlstateclientmanager.cs
- ClientSession.cs
- HtmlTextViewAdapter.cs
- InternalMappingException.cs
- VBCodeProvider.cs
- DetailsViewAutoFormat.cs
- ObjectMaterializedEventArgs.cs
- WpfWebRequestHelper.cs
- XamlToRtfWriter.cs
- CheckableControlBaseAdapter.cs
- Tile.cs
- MailDefinition.cs
- GrammarBuilder.cs
- SiteMapNodeCollection.cs
- SynchronizedInputAdaptor.cs
- OrderByBuilder.cs
- PriorityBindingExpression.cs
- SynchronousChannel.cs
- UserControlCodeDomTreeGenerator.cs
- HostProtectionPermission.cs
- ByteAnimationUsingKeyFrames.cs
- Byte.cs
- ReadOnlyMetadataCollection.cs
- RuntimeArgumentHandle.cs
- EdmItemError.cs
- ImageMap.cs
- EventWaitHandle.cs
- Light.cs
- WaitHandleCannotBeOpenedException.cs
- Update.cs
- DrawingAttributesDefaultValueFactory.cs
- ClassData.cs
- PageThemeCodeDomTreeGenerator.cs
- FrameworkElementAutomationPeer.cs