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
- ColumnMapTranslator.cs
- XmlQueryTypeFactory.cs
- DynamicUpdateCommand.cs
- GenericTypeParameterBuilder.cs
- UInt64.cs
- CheckedListBox.cs
- ConstructorBuilder.cs
- Page.cs
- StylusTip.cs
- CodeIndexerExpression.cs
- ToolboxDataAttribute.cs
- IncrementalHitTester.cs
- DataRelationCollection.cs
- NotConverter.cs
- HtmlSelectionListAdapter.cs
- WebServiceMethodData.cs
- EventProviderWriter.cs
- KeyedHashAlgorithm.cs
- DataGridViewAccessibleObject.cs
- SqlSupersetValidator.cs
- Model3DGroup.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- AddInToken.cs
- HttpContextServiceHost.cs
- NewItemsContextMenuStrip.cs
- PlatformCulture.cs
- InheritanceContextHelper.cs
- ValidationError.cs
- BaseTemplateBuildProvider.cs
- CompModSwitches.cs
- DataRowView.cs
- SapiAttributeParser.cs
- NumberSubstitution.cs
- DoubleConverter.cs
- CurrentChangedEventManager.cs
- CommonObjectSecurity.cs
- ListBoxItemAutomationPeer.cs
- DataSourceGeneratorException.cs
- ListControlConvertEventArgs.cs
- HeaderedContentControl.cs
- DataGridItemAttachedStorage.cs
- XmlWriterTraceListener.cs
- FutureFactory.cs
- AppliedDeviceFiltersDialog.cs
- SafeNativeMethods.cs
- documentsequencetextpointer.cs
- DataControlFieldCollection.cs
- TemplateControlBuildProvider.cs
- OleServicesContext.cs
- StandardBindingImporter.cs
- DbConnectionPoolGroup.cs
- ButtonAutomationPeer.cs
- DescendentsWalkerBase.cs
- FunctionOverloadResolver.cs
- CustomPeerResolverService.cs
- EntityConnectionStringBuilderItem.cs
- UniqueEventHelper.cs
- HierarchicalDataBoundControl.cs
- SecureUICommand.cs
- RectAnimation.cs
- EventMemberCodeDomSerializer.cs
- unsafenativemethodstextservices.cs
- HeaderCollection.cs
- ErrorStyle.cs
- Profiler.cs
- XMLSyntaxException.cs
- CompilationRelaxations.cs
- AppDomainProtocolHandler.cs
- XPathBinder.cs
- Viewport2DVisual3D.cs
- Itemizer.cs
- WindowsListViewSubItem.cs
- MetadataItem_Static.cs
- CodeDefaultValueExpression.cs
- ScriptControlDescriptor.cs
- OracleConnectionFactory.cs
- cookie.cs
- OracleCommand.cs
- MarkedHighlightComponent.cs
- PageTheme.cs
- ProcessHostServerConfig.cs
- XmlSchemaSimpleContent.cs
- MembershipSection.cs
- ToolstripProfessionalRenderer.cs
- HyperLinkStyle.cs
- ContentType.cs
- TraceFilter.cs
- SymDocumentType.cs
- TextEditorTables.cs
- CorruptingExceptionCommon.cs
- FieldReference.cs
- CustomServiceCredentials.cs
- FilteredReadOnlyMetadataCollection.cs
- GenericIdentity.cs
- RegionData.cs
- RawStylusInputCustomDataList.cs
- DropShadowEffect.cs
- XmlNavigatorStack.cs
- TileBrush.cs
- UIElement.cs