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
- TextServicesCompartmentContext.cs
- SignatureDescription.cs
- HandlerFactoryWrapper.cs
- Mapping.cs
- XmlUtilWriter.cs
- ThemeableAttribute.cs
- SourceInterpreter.cs
- ReturnEventArgs.cs
- SystemFonts.cs
- RequestCacheValidator.cs
- MissingSatelliteAssemblyException.cs
- MaterializeFromAtom.cs
- Object.cs
- CookieHandler.cs
- UnsafeNativeMethods.cs
- DeferrableContentConverter.cs
- TreePrinter.cs
- FileCodeGroup.cs
- BulletChrome.cs
- XomlCompilerHelpers.cs
- Transform3D.cs
- SafeProcessHandle.cs
- OneOfConst.cs
- XmlSchemaDatatype.cs
- BindingMemberInfo.cs
- ThreadStaticAttribute.cs
- LambdaCompiler.Unary.cs
- DefaultValueTypeConverter.cs
- PublisherIdentityPermission.cs
- SafeNativeMethods.cs
- MediaTimeline.cs
- WmlMobileTextWriter.cs
- ExpressionBuilderContext.cs
- X509Certificate2.cs
- MissingFieldException.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- Matrix.cs
- UnicodeEncoding.cs
- UserValidatedEventArgs.cs
- UniqueSet.cs
- TextMessageEncoder.cs
- RangeValidator.cs
- ClientSideProviderDescription.cs
- TraceSwitch.cs
- SqlDataSourceSelectingEventArgs.cs
- SchemaCreator.cs
- XmlSchemaAnnotation.cs
- OptimalTextSource.cs
- XmlUrlResolver.cs
- XmlSortKeyAccumulator.cs
- NonSerializedAttribute.cs
- MSAAEventDispatcher.cs
- NullExtension.cs
- TcpChannelFactory.cs
- HtmlTableCellCollection.cs
- HttpApplicationFactory.cs
- IsolatedStorage.cs
- NavigationFailedEventArgs.cs
- SetIterators.cs
- DataGridClipboardHelper.cs
- XPathEmptyIterator.cs
- VirtualPath.cs
- WindowVisualStateTracker.cs
- StringPropertyBuilder.cs
- wgx_render.cs
- ContentPosition.cs
- TemplateApplicationHelper.cs
- MultiByteCodec.cs
- AudioSignalProblemOccurredEventArgs.cs
- ProcessManager.cs
- ConfigXmlSignificantWhitespace.cs
- EntityKey.cs
- PartialCachingControl.cs
- XmlUtil.cs
- ConnectionPointConverter.cs
- CodeCatchClauseCollection.cs
- ResourceIDHelper.cs
- RangeValuePattern.cs
- AsnEncodedData.cs
- EffectiveValueEntry.cs
- DesignBindingPropertyDescriptor.cs
- CallbackValidatorAttribute.cs
- DrawingContextDrawingContextWalker.cs
- XhtmlBasicTextViewAdapter.cs
- WebConfigurationManager.cs
- Base64Decoder.cs
- ProfileGroupSettings.cs
- ToolStripSettings.cs
- ScrollBarRenderer.cs
- ReliableSessionBindingElementImporter.cs
- Control.cs
- GreenMethods.cs
- CapiSymmetricAlgorithm.cs
- UrlMappingsSection.cs
- TogglePatternIdentifiers.cs
- GridViewRowPresenterBase.cs
- storepermissionattribute.cs
- PageAsyncTaskManager.cs
- RootProfilePropertySettingsCollection.cs
- UnsafeNativeMethods.cs