Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EventArgs.cs
- BitmapPalette.cs
- AffineTransform3D.cs
- FileSystemWatcher.cs
- ApplicationTrust.cs
- ReadContentAsBinaryHelper.cs
- SoapIncludeAttribute.cs
- QuaternionAnimationBase.cs
- EdmError.cs
- StringUtil.cs
- Empty.cs
- NotConverter.cs
- UrlMappingsModule.cs
- XPathDescendantIterator.cs
- SwitchCase.cs
- DataConnectionHelper.cs
- DbCommandDefinition.cs
- TagPrefixCollection.cs
- PieceDirectory.cs
- ServiceBehaviorElementCollection.cs
- RSAOAEPKeyExchangeFormatter.cs
- Rules.cs
- AuthenticodeSignatureInformation.cs
- ScriptResourceHandler.cs
- SafePointer.cs
- BitmapScalingModeValidation.cs
- GeometryCollection.cs
- CacheRequest.cs
- WindowShowOrOpenTracker.cs
- SqlParameterizer.cs
- StylusButtonCollection.cs
- SoapAttributeAttribute.cs
- BrowserPolicyValidator.cs
- BadImageFormatException.cs
- XmlWellformedWriter.cs
- CachedFontFace.cs
- NegotiationTokenAuthenticatorStateCache.cs
- ADRoleFactory.cs
- WebPartUserCapability.cs
- SecurityStateEncoder.cs
- AuditLogLocation.cs
- SqlDataSourceQueryEditorForm.cs
- TextElementCollectionHelper.cs
- CodeMethodReturnStatement.cs
- Aggregates.cs
- SystemWebSectionGroup.cs
- VirtualPath.cs
- BufferBuilder.cs
- RemotingConfigParser.cs
- loginstatus.cs
- Registry.cs
- Random.cs
- BuildResult.cs
- AsmxEndpointPickerExtension.cs
- EntityReference.cs
- BoundPropertyEntry.cs
- Overlapped.cs
- BypassElementCollection.cs
- XsltLoader.cs
- HijriCalendar.cs
- CornerRadiusConverter.cs
- FixedPageStructure.cs
- SmtpCommands.cs
- ThemeableAttribute.cs
- SQLDateTimeStorage.cs
- DPAPIProtectedConfigurationProvider.cs
- AppPool.cs
- MetadataItemEmitter.cs
- DateTimeParse.cs
- SettingsPropertyValueCollection.cs
- OletxVolatileEnlistment.cs
- WebPartAddingEventArgs.cs
- Parameter.cs
- SchemaImporter.cs
- FileLogRecord.cs
- MetadataWorkspace.cs
- CreateUserWizard.cs
- StringToken.cs
- ReplyChannelAcceptor.cs
- UIElement3D.cs
- SetStoryboardSpeedRatio.cs
- SemanticValue.cs
- PageEventArgs.cs
- ActiveXHelper.cs
- OdbcParameterCollection.cs
- UnionExpr.cs
- SafeSerializationManager.cs
- SiteMapProvider.cs
- RowBinding.cs
- ComponentCommands.cs
- ObservableCollection.cs
- UnitySerializationHolder.cs
- XNodeValidator.cs
- WrapperEqualityComparer.cs
- TextServicesCompartmentEventSink.cs
- EmptyStringExpandableObjectConverter.cs
- ProjectionCamera.cs
- BuildProvider.cs
- PersistChildrenAttribute.cs
- DataReceivedEventArgs.cs