Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / DoWhile.cs / 1305376 / DoWhile.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Statements { using System.Activities; using System.Activities.Expressions; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq.Expressions; using System.Runtime; using System.Runtime.Collections; using System.Windows.Markup; [ContentProperty("Body")] public sealed class DoWhile : NativeActivity { CompletionCallback onBodyComplete; CompletionCallbackonConditionComplete; Collection variables; public DoWhile() : base() { } public DoWhile(Expression > condition) : this() { if (condition == null) { throw FxTrace.Exception.ArgumentNull("condition"); } this.Condition = new LambdaValue (condition); } public DoWhile(Activity condition) : this() { if (condition == null) { throw FxTrace.Exception.ArgumentNull("condition"); } this.Condition = condition; } public Collection Variables { get { if (this.variables == null) { this.variables = new ValidatingCollection { // disallow null values OnAddValidationCallback = item => { if (item == null) { throw FxTrace.Exception.ArgumentNull("item"); } } }; } return this.variables; } } [DefaultValue(null)] [DependsOn("Variables")] public Activity Condition { get; set; } [DefaultValue(null)] [DependsOn("Condition")] public Activity Body { get; set; } protected override void CacheMetadata(NativeActivityMetadata metadata) { metadata.SetVariablesCollection(this.Variables); if (this.Condition == null) { metadata.AddValidationError(SR.DoWhileRequiresCondition(this.DisplayName)); } else { metadata.AddChild(this.Condition); } metadata.AddChild(this.Body); } protected override void Execute(NativeActivityContext context) { // initial logic is the same as when the condition completes with true OnConditionComplete(context, null, true); } void ScheduleCondition(NativeActivityContext context) { Fx.Assert(this.Condition != null, "validated in OnOpen"); if (this.onConditionComplete == null) { this.onConditionComplete = new CompletionCallback (OnConditionComplete); } context.ScheduleActivity(this.Condition, this.onConditionComplete); } void OnConditionComplete(NativeActivityContext context, ActivityInstance completedInstance, bool result) { if (result) { if (this.Body != null) { if (this.onBodyComplete == null) { this.onBodyComplete = new CompletionCallback(OnBodyComplete); } context.ScheduleActivity(this.Body, this.onBodyComplete); } else { ScheduleCondition(context); } } } void OnBodyComplete(NativeActivityContext context, ActivityInstance completedInstance) { ScheduleCondition(context); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TreeNode.cs
- PrintDialog.cs
- JournalEntry.cs
- VisemeEventArgs.cs
- XmlKeywords.cs
- EventSinkActivityDesigner.cs
- TokenBasedSet.cs
- SupportsPreviewControlAttribute.cs
- Emitter.cs
- WebException.cs
- TextElementEditingBehaviorAttribute.cs
- PointHitTestResult.cs
- StylusPointPropertyInfo.cs
- XmlNavigatorStack.cs
- HtmlWindow.cs
- Function.cs
- ComplusEndpointConfigContainer.cs
- GeneralTransform2DTo3DTo2D.cs
- MemberRelationshipService.cs
- MessageQueueKey.cs
- ColumnBinding.cs
- ItemCollection.cs
- XmlElement.cs
- DataGridViewRowsAddedEventArgs.cs
- MessageSecurityException.cs
- DictionarySurrogate.cs
- AdornerLayer.cs
- ArrangedElement.cs
- AddInToken.cs
- DockingAttribute.cs
- RefExpr.cs
- NamedPipeConnectionPool.cs
- SQlBooleanStorage.cs
- CustomDictionarySources.cs
- BufferAllocator.cs
- QuotaThrottle.cs
- SchemaInfo.cs
- EnumValAlphaComparer.cs
- DiscoveryClientDuplexChannel.cs
- LineBreak.cs
- XmlObjectSerializer.cs
- UnsafeNativeMethods.cs
- ipaddressinformationcollection.cs
- ToolStripPanelCell.cs
- SchemaTypeEmitter.cs
- QueryServiceConfigHandle.cs
- StatusBarDrawItemEvent.cs
- StoreContentChangedEventArgs.cs
- SmiRequestExecutor.cs
- ResourceCategoryAttribute.cs
- AccessedThroughPropertyAttribute.cs
- SqlCommandSet.cs
- GlyphInfoList.cs
- RegexMatch.cs
- EntityDataSourceChangingEventArgs.cs
- ReferentialConstraint.cs
- TypeBuilder.cs
- OdbcFactory.cs
- TreeNodeClickEventArgs.cs
- TextBounds.cs
- BrowserCapabilitiesFactoryBase.cs
- Binding.cs
- GuidTagList.cs
- ExpressionVisitor.cs
- OutputScopeManager.cs
- Size3DConverter.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- StrongNameHelpers.cs
- StrokeRenderer.cs
- PropertyInfoSet.cs
- ClassHandlersStore.cs
- StringConverter.cs
- SchemaAttDef.cs
- RuntimeConfig.cs
- SamlAttributeStatement.cs
- TextBreakpoint.cs
- DBPropSet.cs
- ToolStripDropDownButton.cs
- HtmlGenericControl.cs
- DropDownList.cs
- ColumnReorderedEventArgs.cs
- METAHEADER.cs
- Vector.cs
- ObjectPersistData.cs
- DocumentReference.cs
- BadImageFormatException.cs
- CustomPopupPlacement.cs
- WebPartManager.cs
- SinglePageViewer.cs
- HuffModule.cs
- DbConnectionOptions.cs
- DocumentSchemaValidator.cs
- DataGridRow.cs
- ViewManager.cs
- Vars.cs
- DeclarationUpdate.cs
- DataViewManager.cs
- EntitySqlQueryState.cs
- XmlException.cs
- SimpleBitVector32.cs