Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / HandleInitializationContext.cs / 1305376 / HandleInitializationContext.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities { using System; using System.Activities.Runtime; using System.Diagnostics.CodeAnalysis; using System.Runtime; [Fx.Tag.XamlVisible(false)] public sealed class HandleInitializationContext { ActivityExecutor executor; ActivityInstance scope; bool isDiposed; internal HandleInitializationContext(ActivityExecutor executor, ActivityInstance scope) { this.executor = executor; this.scope = scope; } internal ActivityInstance OwningActivityInstance { get { return this.scope; } } internal ActivityExecutor Executor { get { return this.executor; } } public THandle CreateAndInitializeHandle() where THandle : Handle { ThrowIfDisposed(); THandle value = Activator.CreateInstance (); value.Initialize(this); // If we have a scope, we need to add this new handle to the LocationEnvironment. if (this.scope != null) { this.scope.Environment.AddHandle(value); } // otherwise add it to the Executor. else { this.executor.AddHandle(value); } return value; } public void UninitializeHandle(Handle handle) { ThrowIfDisposed(); handle.Uninitialize(this); } internal object CreateAndInitializeHandle(Type handleType) { Fx.Assert(ActivityUtilities.IsHandle(handleType), "This should only be called with Handle subtypes."); object value = Activator.CreateInstance(handleType); ((Handle)value).Initialize(this); // If we have a scope, we need to add this new handle to the LocationEnvironment. if (this.scope != null) { this.scope.Environment.AddHandle((Handle)value); } // otherwise add it to the Executor. else { this.executor.AddHandle((Handle)value); } return value; } internal BookmarkScope CreateAndRegisterBookmarkScope() { return this.executor.BookmarkScopeManager.CreateAndRegisterScope(Guid.Empty); } internal void UnregisterBookmarkScope(BookmarkScope bookmarkScope) { Fx.Assert(bookmarkScope != null, "The sub instance should not equal null."); this.executor.BookmarkScopeManager.UnregisterScope(bookmarkScope); } void ThrowIfDisposed() { if (this.isDiposed) { throw FxTrace.Exception.AsError(new ObjectDisposedException(SR.HandleInitializationContextDisposed)); } } internal void Dispose() { this.isDiposed = true; } } } // 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
- UrlParameterReader.cs
- PackageDigitalSignatureManager.cs
- VisualBrush.cs
- AspNetHostingPermission.cs
- XmlIgnoreAttribute.cs
- List.cs
- DataGridDesigner.cs
- Screen.cs
- ActivityDesigner.cs
- BlurEffect.cs
- BitmapMetadataEnumerator.cs
- Currency.cs
- BindingListCollectionView.cs
- ToolStripLocationCancelEventArgs.cs
- HttpModulesSection.cs
- MonthCalendar.cs
- EntitySetBaseCollection.cs
- ScrollBar.cs
- TextParagraphCache.cs
- MessagePropertyAttribute.cs
- XPathParser.cs
- PerformanceCounterManager.cs
- AttributeUsageAttribute.cs
- AutoGeneratedFieldProperties.cs
- WebConfigurationManager.cs
- OutOfProcStateClientManager.cs
- ReturnType.cs
- WrapPanel.cs
- PeerObject.cs
- WebPartUtil.cs
- OdbcDataReader.cs
- DataObjectCopyingEventArgs.cs
- FontUnit.cs
- XslTransformFileEditor.cs
- JsonSerializer.cs
- CryptographicAttribute.cs
- ToolStripContentPanelRenderEventArgs.cs
- DoubleKeyFrameCollection.cs
- ReadContentAsBinaryHelper.cs
- ItemContainerGenerator.cs
- mediaeventshelper.cs
- ProcessInfo.cs
- EventProvider.cs
- XmlWriter.cs
- PathBox.cs
- ToolStripRenderEventArgs.cs
- PingReply.cs
- HitTestFilterBehavior.cs
- TextDocumentView.cs
- ConfigXmlText.cs
- TraceLevelStore.cs
- Material.cs
- COM2FontConverter.cs
- FixedSOMTable.cs
- XmlIterators.cs
- WebPartConnectionsCloseVerb.cs
- SqlDependencyListener.cs
- DesignerProperties.cs
- SqlUserDefinedTypeAttribute.cs
- DistributedTransactionPermission.cs
- Perspective.cs
- ResumeStoryboard.cs
- RolePrincipal.cs
- TextRangeBase.cs
- TrackingMemoryStreamFactory.cs
- UiaCoreApi.cs
- ToolStripScrollButton.cs
- SqlGatherConsumedAliases.cs
- PageCatalogPart.cs
- RegexFCD.cs
- WebPartCloseVerb.cs
- LinqDataView.cs
- ReflectPropertyDescriptor.cs
- TextMetrics.cs
- EventLog.cs
- TreeNodeBinding.cs
- CollectionViewSource.cs
- ImpersonationContext.cs
- SQLString.cs
- SafeLibraryHandle.cs
- QuaternionRotation3D.cs
- BrowserCapabilitiesFactory.cs
- CodeLinePragma.cs
- CodeGeneratorAttribute.cs
- OptimizedTemplateContent.cs
- ShaperBuffers.cs
- ExpandSegment.cs
- SoapTypeAttribute.cs
- RenderData.cs
- SynchronizationScope.cs
- SchemaImporter.cs
- BindingExpressionBase.cs
- System.Data_BID.cs
- AsyncStreamReader.cs
- MemberProjectedSlot.cs
- XmlAggregates.cs
- CapacityStreamGeometryContext.cs
- namescope.cs
- MemoryRecordBuffer.cs
- SubMenuStyle.cs