Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / DynamicActivity.cs / 1305376 / DynamicActivity.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System;
using System.Activities.Runtime;
using System.Activities.Validation;
using System.Activities.XamlIntegration;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime;
using System.Windows.Markup;
using System.Xaml;
[ContentProperty("Implementation")]
public sealed class DynamicActivity : Activity, ICustomTypeDescriptor, IDynamicActivity
{
Activity runtimeImplementation;
DynamicActivityTypeDescriptor typeDescriptor;
Collection attributes;
public DynamicActivity()
: base()
{
this.typeDescriptor = new DynamicActivityTypeDescriptor(this);
}
public string Name
{
get
{
return this.typeDescriptor.Name;
}
set
{
this.typeDescriptor.Name = value;
}
}
[DependsOn("Name")]
public Collection Attributes
{
get
{
if (this.attributes == null)
{
this.attributes = new Collection();
}
return this.attributes;
}
}
[Browsable(false)]
[DependsOn("Attributes")]
public KeyedCollection Properties
{
get
{
return this.typeDescriptor.Properties;
}
}
[DependsOn("Properties")]
public new Collection Constraints
{
get
{
return base.Constraints;
}
}
[XamlDeferLoad(typeof(FuncDeferringLoader), typeof(Activity))]
[DefaultValue(null)]
[Browsable(false)]
[Ambient]
public new Func Implementation
{
get
{
return base.Implementation;
}
set
{
base.Implementation = value;
}
}
KeyedCollection IDynamicActivity.Properties
{
get
{
return this.Properties;
}
}
internal override void InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
{
if (this.runtimeImplementation != null)
{
executor.ScheduleActivity(this.runtimeImplementation, instance, null, null, null);
}
}
sealed internal override void OnInternalCacheMetadata(bool createEmptyBindings)
{
Activity body = null;
if (this.Implementation != null)
{
body = this.Implementation();
}
if (body != null)
{
SetImplementationChildrenCollection(new Collection { body });
}
// Always cache the last body that we returned
this.runtimeImplementation = body;
ReflectedInformation information = new ReflectedInformation(this);
SetImportedChildrenCollection(information.GetChildren());
SetVariablesCollection(information.GetVariables());
SetImportedDelegatesCollection(information.GetDelegates());
SetArgumentsCollection(information.GetArguments(), createEmptyBindings);
}
AttributeCollection ICustomTypeDescriptor.GetAttributes()
{
return this.typeDescriptor.GetAttributes();
}
string ICustomTypeDescriptor.GetClassName()
{
return this.typeDescriptor.GetClassName();
}
string ICustomTypeDescriptor.GetComponentName()
{
return this.typeDescriptor.GetComponentName();
}
TypeConverter ICustomTypeDescriptor.GetConverter()
{
return this.typeDescriptor.GetConverter();
}
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
{
return this.typeDescriptor.GetDefaultEvent();
}
PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
{
return this.typeDescriptor.GetDefaultProperty();
}
object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
{
return this.typeDescriptor.GetEditor(editorBaseType);
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
{
return this.typeDescriptor.GetEvents(attributes);
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
return this.typeDescriptor.GetEvents();
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
{
return this.typeDescriptor.GetProperties();
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
{
return this.typeDescriptor.GetProperties(attributes);
}
object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
{
return this.typeDescriptor.GetPropertyOwner(pd);
}
}
[ContentProperty("Implementation")]
public sealed class DynamicActivity : Activity, ICustomTypeDescriptor, IDynamicActivity
{
Activity runtimeImplementation;
DynamicActivityTypeDescriptor typeDescriptor;
Collection attributes;
public DynamicActivity()
: base()
{
this.typeDescriptor = new DynamicActivityTypeDescriptor(this);
}
public string Name
{
get
{
return this.typeDescriptor.Name;
}
set
{
this.typeDescriptor.Name = value;
}
}
[DependsOn("Name")]
public Collection Attributes
{
get
{
if (this.attributes == null)
{
this.attributes = new Collection();
}
return this.attributes;
}
}
[Browsable(false)]
[DependsOn("Attributes")]
public KeyedCollection Properties
{
get
{
return this.typeDescriptor.Properties;
}
}
[DependsOn("Properties")]
public new Collection Constraints
{
get
{
return base.Constraints;
}
}
[XamlDeferLoad(typeof(FuncDeferringLoader), typeof(Activity))]
[DefaultValue(null)]
[Browsable(false)]
[Ambient]
public new Func Implementation
{
get
{
return base.Implementation;
}
set
{
base.Implementation = value;
}
}
KeyedCollection IDynamicActivity.Properties
{
get
{
return this.Properties;
}
}
internal override void InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
{
if (this.runtimeImplementation != null)
{
executor.ScheduleActivity(this.runtimeImplementation, instance, null, null, null);
}
}
sealed internal override void OnInternalCacheMetadataExceptResult(bool createEmptyBindings)
{
Activity body = null;
if (this.Implementation != null)
{
body = this.Implementation();
}
if (body != null)
{
SetImplementationChildrenCollection(new Collection { body });
}
// Always cache the last body that we returned
this.runtimeImplementation = body;
ReflectedInformation information = new ReflectedInformation(this);
SetImportedChildrenCollection(information.GetChildren());
SetVariablesCollection(information.GetVariables());
SetImportedDelegatesCollection(information.GetDelegates());
SetArgumentsCollection(information.GetArguments(), createEmptyBindings);
}
AttributeCollection ICustomTypeDescriptor.GetAttributes()
{
return this.typeDescriptor.GetAttributes();
}
string ICustomTypeDescriptor.GetClassName()
{
return this.typeDescriptor.GetClassName();
}
string ICustomTypeDescriptor.GetComponentName()
{
return this.typeDescriptor.GetComponentName();
}
TypeConverter ICustomTypeDescriptor.GetConverter()
{
return this.typeDescriptor.GetConverter();
}
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
{
return this.typeDescriptor.GetDefaultEvent();
}
PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
{
return this.typeDescriptor.GetDefaultProperty();
}
object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
{
return this.typeDescriptor.GetEditor(editorBaseType);
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
{
return this.typeDescriptor.GetEvents(attributes);
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
return this.typeDescriptor.GetEvents();
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
{
return this.typeDescriptor.GetProperties();
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
{
return this.typeDescriptor.GetProperties(attributes);
}
object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
{
return this.typeDescriptor.GetPropertyOwner(pd);
}
}
}
// 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
- iisPickupDirectory.cs
- ViewPort3D.cs
- ControlOperationBehavior.cs
- Pen.cs
- ConditionCollection.cs
- EventDescriptor.cs
- processwaithandle.cs
- PartitionResolver.cs
- ObjRef.cs
- BlurBitmapEffect.cs
- SendKeys.cs
- HandoffBehavior.cs
- WpfKnownTypeInvoker.cs
- RequestCacheValidator.cs
- PersonalizationDictionary.cs
- Util.cs
- HMACRIPEMD160.cs
- EventListener.cs
- HtmlAnchor.cs
- MaterialGroup.cs
- ResourceDictionaryCollection.cs
- SerialStream.cs
- COM2FontConverter.cs
- Zone.cs
- IteratorFilter.cs
- ResourceContainer.cs
- Menu.cs
- DataGridPagerStyle.cs
- FormsAuthenticationEventArgs.cs
- WindowsMenu.cs
- BinaryNode.cs
- HtmlValidationSummaryAdapter.cs
- SubMenuStyle.cs
- XMLUtil.cs
- Package.cs
- WebPartDisplayModeCancelEventArgs.cs
- XamlInt32CollectionSerializer.cs
- XPathScanner.cs
- ByteStorage.cs
- ExpressionEvaluator.cs
- GridLengthConverter.cs
- IncrementalCompileAnalyzer.cs
- RoleManagerEventArgs.cs
- GlyphElement.cs
- XPathDescendantIterator.cs
- SerializationException.cs
- TrackBarDesigner.cs
- ReflectPropertyDescriptor.cs
- MenuItem.cs
- GeneralTransform3DGroup.cs
- MultilineStringConverter.cs
- ProjectionQueryOptionExpression.cs
- Wildcard.cs
- RTLAwareMessageBox.cs
- FileSystemEventArgs.cs
- DataSetFieldSchema.cs
- PropertyChangedEventManager.cs
- TextParagraphProperties.cs
- coordinatorscratchpad.cs
- DataGridViewColumnStateChangedEventArgs.cs
- SQLDoubleStorage.cs
- GridViewHeaderRowPresenter.cs
- CompositionTarget.cs
- KerberosSecurityTokenProvider.cs
- ProxyWebPartManager.cs
- PolicyAssertionCollection.cs
- HandledMouseEvent.cs
- DatagridviewDisplayedBandsData.cs
- SchemaSetCompiler.cs
- AspCompat.cs
- DbDataRecord.cs
- DesignTimeTemplateParser.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- XomlCompilerResults.cs
- TagMapCollection.cs
- CalendarAutoFormatDialog.cs
- Bits.cs
- ColorMap.cs
- InfoCardArgumentException.cs
- SByteConverter.cs
- PrePrepareMethodAttribute.cs
- DataGridView.cs
- OperationGenerator.cs
- UTF7Encoding.cs
- DataFormats.cs
- SettingsContext.cs
- CharStorage.cs
- DataViewListener.cs
- DataGridViewColumnStateChangedEventArgs.cs
- RTTrackingProfile.cs
- SqlCaseSimplifier.cs
- CommonBehaviorsSection.cs
- Parser.cs
- DataServiceRequestOfT.cs
- OAVariantLib.cs
- SystemThemeKey.cs
- IndexedEnumerable.cs
- OleDbParameter.cs
- BaseCodeDomTreeGenerator.cs
- RichTextBoxContextMenu.cs