Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / HandleScope.cs / 1305376 / HandleScope.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Statements { using System.Activities; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime; using System.Windows.Markup; [ContentProperty("Body")] public sealed class HandleScope: NativeActivity where THandle : Handle { Variable declaredHandle; public HandleScope() { } public InArgument Handle { get; set; } public Activity Body { get; set; } protected override void CacheMetadata(NativeActivityMetadata metadata) { RuntimeArgument handleArgument = new RuntimeArgument("Handle", typeof(THandle), ArgumentDirection.In); metadata.Bind(this.Handle, handleArgument); metadata.SetArgumentsCollection(new Collection { handleArgument }); if (this.Body != null) { metadata.SetChildrenCollection(new Collection { this.Body }); } Collection implementationVariables = null; if ((this.Handle == null) || this.Handle.IsEmpty) { if (this.declaredHandle == null) { this.declaredHandle = new Variable (); } } else { this.declaredHandle = null; } if (this.declaredHandle != null) { ActivityUtilities.Add(ref implementationVariables, this.declaredHandle); } metadata.SetImplementationVariablesCollection(implementationVariables); } protected override void Execute(NativeActivityContext context) { // We should go through the motions even if there is no Body for debugging // purposes. When testing handles people will probably use empty scopes // expecting everything except the Body execution to occur. Handle scopedHandle = null; if ((this.Handle == null) || this.Handle.IsEmpty) { Fx.Assert(this.declaredHandle != null, "We should have declared the variable if we didn't have the argument set."); scopedHandle = this.declaredHandle.Get(context); } else { scopedHandle = this.Handle.Get(context); } if (scopedHandle == null) { throw FxTrace.Exception.ArgumentNull("Handle"); } context.Properties.Add(scopedHandle.ExecutionPropertyName, scopedHandle); if (this.Body != null) { context.ScheduleActivity(this.Body); } } } } // 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
- ConfigurationCollectionAttribute.cs
- StringUtil.cs
- JpegBitmapDecoder.cs
- EntityStoreSchemaFilterEntry.cs
- SafeNativeMethodsOther.cs
- XmlMapping.cs
- XamlVector3DCollectionSerializer.cs
- SignatureResourcePool.cs
- ModelTreeEnumerator.cs
- DictionaryEntry.cs
- HijriCalendar.cs
- ParameterCollection.cs
- IntSumAggregationOperator.cs
- EncoderParameters.cs
- Rect3DConverter.cs
- IncrementalReadDecoders.cs
- CategoryGridEntry.cs
- Utilities.cs
- SchemaDeclBase.cs
- WmlCalendarAdapter.cs
- DataRowCollection.cs
- AuthorizationRuleCollection.cs
- BufferModeSettings.cs
- _UriTypeConverter.cs
- StatusBarItem.cs
- BitConverter.cs
- CodeGotoStatement.cs
- SegmentInfo.cs
- ParameterCollection.cs
- ByteStack.cs
- Point3DValueSerializer.cs
- AddingNewEventArgs.cs
- _IPv4Address.cs
- WsdlBuildProvider.cs
- IntegrationExceptionEventArgs.cs
- TextElementAutomationPeer.cs
- COAUTHINFO.cs
- StringCollectionEditor.cs
- SchemaNames.cs
- SystemTcpConnection.cs
- FileCodeGroup.cs
- HtmlWindowCollection.cs
- ViewService.cs
- MetadataFile.cs
- StoreContentChangedEventArgs.cs
- Binding.cs
- QueryableDataSourceView.cs
- ToolStripContentPanel.cs
- ConnectorSelectionGlyph.cs
- ApplicationDirectory.cs
- SecurityResources.cs
- OracleColumn.cs
- FrameworkElementFactoryMarkupObject.cs
- DoubleLinkList.cs
- VisualTarget.cs
- InvokePattern.cs
- ActiveXContainer.cs
- GridPatternIdentifiers.cs
- LinearGradientBrush.cs
- ProvidersHelper.cs
- URL.cs
- XmlQueryOutput.cs
- WebScriptServiceHostFactory.cs
- Bits.cs
- NegotiationTokenProvider.cs
- ProcessHostConfigUtils.cs
- UshortList2.cs
- DefaultValueAttribute.cs
- New.cs
- RadialGradientBrush.cs
- XPathParser.cs
- MethodRental.cs
- DocumentPage.cs
- ZipIOLocalFileHeader.cs
- ConfigurationException.cs
- BrowserCapabilitiesCompiler.cs
- NetSectionGroup.cs
- XmlAttributeProperties.cs
- ModifyActivitiesPropertyDescriptor.cs
- WebPartZoneBase.cs
- MaterialGroup.cs
- BaseParser.cs
- DetailsViewDeleteEventArgs.cs
- ApplicationFileCodeDomTreeGenerator.cs
- PointAnimationUsingPath.cs
- CodeChecksumPragma.cs
- CommonObjectSecurity.cs
- RawStylusInputReport.cs
- XamlReaderConstants.cs
- NavigationExpr.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- Int16AnimationBase.cs
- MetadataPropertyCollection.cs
- XslAst.cs
- DocumentXmlWriter.cs
- OleDbConnectionInternal.cs
- StreamInfo.cs
- WinFormsComponentEditor.cs
- FixedElement.cs
- HashHelper.cs