Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,370 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.Activities
{
using System.Activities.Debugger;
using System.Activities.Validation;
using System.Activities.XamlIntegration;
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 ActivityBuilder : IDebuggableWorkflowTree
{
// define attached properties that will identify PropertyReferenceExtension-based
// object properties
static AttachableMemberIdentifier propertyReferencePropertyID = new AttachableMemberIdentifier(typeof(ActivityBuilder), "PropertyReference");
static AttachableMemberIdentifier propertyReferencesPropertyID = new AttachableMemberIdentifier(typeof(ActivityBuilder), "PropertyReferences");
KeyedCollection<string, DynamicActivityProperty> properties;
Collection<Constraint> constraints;
Collection<Attribute> attributes;
public ActivityBuilder()
{
}
public string Name
{
get;
set;
}
[DependsOn("Name")]
public Collection<Attribute> Attributes
{
get
{
if (this.attributes == null)
{
this.attributes = new Collection<Attribute>();
}
return this.attributes;
}
}
[Browsable(false)]
[DependsOn("Attributes")]
public KeyedCollection<string, DynamicActivityProperty> Properties
{
get
{
if (this.properties == null)
{
this.properties = new ActivityPropertyCollection();
}
return this.properties;
}
}
[DependsOn("Properties")]
[Browsable(false)]
public Collection<Constraint> Constraints
{
get
{
if (this.constraints == null)
{
this.constraints = new Collection<Constraint>();
}
return this.constraints;
}
}
[TypeConverter(typeof(ImplementationVersionConverter))]
[DefaultValue(null)]
[DependsOn("Name")]
public Version ImplementationVersion
{
get;
set;
}
[DefaultValue(null)]
[Browsable(false)]
[DependsOn("Constraints")]
public Activity Implementation
{
get;
set;
}
// Back-compat workaround: PropertyReference shipped in 4.0. PropertyReferences is new in 4.5.
//
// Requirements:
// - Runtime compat: Get/SetPropertyReference needs to continue to work, both when set programatically
// and when loading a doc which contains only one PropertyReference on an object.
// - Serialization compat: If only one PropertyReference was set, we shouldn't serialize PropertyReferences.
// (Only affects when ActivityBuilder is used directly with XamlServices, since ActivityXamlServices
// will convert ActivityPropertyReference to PropertyReferenceExtension.)
// - Usability: To avoid the designer needing to support two separate access methods, we want
// the value from SetPropertyReference to also appear in the PropertyReferences collection.
// <ActivityBuilder.PropertyReference>activity property name</ActivityBuilder.PropertyReference>
public static ActivityPropertyReference GetPropertyReference(object target)
{
return GetPropertyReferenceCollection(target).SingleItem;
}
// <ActivityBuilder.PropertyReference>activity property name</ActivityBuilder.PropertyReference>
public static void SetPropertyReference(object target, ActivityPropertyReference value)
{
GetPropertyReferenceCollection(target).SingleItem = value;
}
public static IList<ActivityPropertyReference> GetPropertyReferences(object target)
{
return GetPropertyReferenceCollection(target);
}
public static bool ShouldSerializePropertyReference(object target)
{
PropertyReferenceCollection propertyReferences = GetPropertyReferenceCollection(target);
return propertyReferences.Count == 1 && propertyReferences.SingleItem != null;
}
public static bool ShouldSerializePropertyReferences(object target)
{
PropertyReferenceCollection propertyReferences = GetPropertyReferenceCollection(target);
return propertyReferences.Count > 1 || propertyReferences.SingleItem == null;
}
internal static bool HasPropertyReferences(object target)
{
PropertyReferenceCollection propertyReferences;
if (AttachablePropertyServices.TryGetProperty(target, propertyReferencesPropertyID, out propertyReferences))
{
return propertyReferences.Count > 0;
}
return false;
}
static PropertyReferenceCollection GetPropertyReferenceCollection(object target)
{
PropertyReferenceCollection propertyReferences;
if (!AttachablePropertyServices.TryGetProperty(target, propertyReferencesPropertyID, out propertyReferences))
{
propertyReferences = new PropertyReferenceCollection(target);
AttachablePropertyServices.SetProperty(target, propertyReferencesPropertyID, propertyReferences);
}
return propertyReferences;
}
Activity IDebuggableWorkflowTree.GetWorkflowRoot()
{
return this.Implementation;
}
internal static KeyedCollection<string, DynamicActivityProperty> CreateActivityPropertyCollection()
{
return new ActivityPropertyCollection();
}
class ActivityPropertyCollection : KeyedCollection<string, DynamicActivityProperty>
{
protected override string GetKeyForItem(DynamicActivityProperty item)
{
return item.Name;
}
}
// See back-compat requirements in comment above. Design is:
// - First value added to collection when it is empty becomes the single PropertyReference value
// - If the single value is removed, then PropertyReference AP is removed
// - If PropertyReference AP is set to null, we remove the single value.
// - If PropertyReference is set to non-null, we replace the existing single value if there
// is one, or else add the new value to the collection.
class PropertyReferenceCollection : Collection<ActivityPropertyReference>
{
WeakReference targetObject;
int singleItemIndex = -1;
public PropertyReferenceCollection(object target)
{
this.targetObject = new WeakReference(target);
}
public ActivityPropertyReference SingleItem
{
get
{
return this.singleItemIndex >= 0 ? this[this.singleItemIndex] : null;
}
set
{
if (this.singleItemIndex >= 0)
{
if (value != null)
{
SetItem(this.singleItemIndex, value);
}
else
{
RemoveItem(this.singleItemIndex);
}
}
else if (value != null)
{
Add(value);
if (Count > 1)
{
this.singleItemIndex = Count - 1;
UpdateAttachedProperty();
}
}
}
}
protected override void ClearItems()
{
this.singleItemIndex = -1;
UpdateAttachedProperty();
}
protected override void InsertItem(int index, ActivityPropertyReference item)
{
base.InsertItem(index, item);
if (index <= this.singleItemIndex)
{
this.singleItemIndex++;
}
else if (Count == 1)
{
Fx.Assert(this.singleItemIndex < 0, "How did we have an index if we were empty?");
this.singleItemIndex = 0;
UpdateAttachedProperty();
}
}
protected override void RemoveItem(int index)
{
base.RemoveItem(index);
if (index < this.singleItemIndex)
{
this.singleItemIndex--;
}
else if (index == this.singleItemIndex)
{
this.singleItemIndex = -1;
UpdateAttachedProperty();
}
}
protected override void SetItem(int index, ActivityPropertyReference item)
{
base.SetItem(index, item);
if (index == this.singleItemIndex)
{
UpdateAttachedProperty();
}
}
void UpdateAttachedProperty()
{
object target = this.targetObject.Target;
if (target != null)
{
if (this.singleItemIndex >= 0)
{
AttachablePropertyServices.SetProperty(target, propertyReferencePropertyID, this[this.singleItemIndex]);
}
else
{
AttachablePropertyServices.RemoveProperty(target, propertyReferencePropertyID);
}
}
}
}
}
[ContentProperty("Implementation")]
public sealed class ActivityBuilder<TResult> : IDebuggableWorkflowTree
{
KeyedCollection<string, DynamicActivityProperty> properties;
Collection<Constraint> constraints;
Collection<Attribute> attributes;
public ActivityBuilder()
{
}
public string Name
{
get;
set;
}
[DependsOn("Name")]
public Collection<Attribute> Attributes
{
get
{
if (this.attributes == null)
{
this.attributes = new Collection<Attribute>();
}
return this.attributes;
}
}
[Browsable(false)]
[DependsOn("Attributes")]
public KeyedCollection<string, DynamicActivityProperty> Properties
{
get
{
if (this.properties == null)
{
this.properties = ActivityBuilder.CreateActivityPropertyCollection();
}
return this.properties;
}
}
[DependsOn("Properties")]
[Browsable(false)]
public Collection<Constraint> Constraints
{
get
{
if (this.constraints == null)
{
this.constraints = new Collection<Constraint>();
}
return this.constraints;
}
}
[TypeConverter(typeof(ImplementationVersionConverter))]
[DefaultValue(null)]
[DependsOn("Name")]
public Version ImplementationVersion
{
get;
set;
}
[DefaultValue(null)]
[Browsable(false)]
[DependsOn("Constraints")]
public Activity Implementation
{
get;
set;
}
Activity IDebuggableWorkflowTree.GetWorkflowRoot()
{
return this.Implementation;
}
}
}

View File

@@ -0,0 +1,13 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
enum ActivityCollectionType
{
Public,
Imports,
Implementation
}
}

View File

@@ -0,0 +1,450 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System;
using System.Activities.Runtime;
using System.Activities.Tracking;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime;
[Fx.Tag.XamlVisible(false)]
public class ActivityContext
{
ActivityInstance instance;
ActivityExecutor executor;
bool isDisposed;
long instanceId;
// Used by subclasses that are pooled.
internal ActivityContext()
{
}
// these can only be created by the WF Runtime
internal ActivityContext(ActivityInstance instance, ActivityExecutor executor)
{
Fx.Assert(instance != null, "valid activity instance is required");
this.instance = instance;
this.executor = executor;
this.Activity = this.instance.Activity;
this.instanceId = instance.InternalId;
}
internal LocationEnvironment Environment
{
get
{
ThrowIfDisposed();
return this.instance.Environment;
}
}
internal bool AllowChainedEnvironmentAccess
{
get;
set;
}
internal Activity Activity
{
get;
private set;
}
internal ActivityInstance CurrentInstance
{
get
{
return this.instance;
}
}
internal ActivityExecutor CurrentExecutor
{
get
{
return this.executor;
}
}
public string ActivityInstanceId
{
get
{
ThrowIfDisposed();
return this.instanceId.ToString(CultureInfo.InvariantCulture);
}
}
public Guid WorkflowInstanceId
{
get
{
ThrowIfDisposed();
return this.executor.WorkflowInstanceId;
}
}
public WorkflowDataContext DataContext
{
get
{
ThrowIfDisposed();
// Argument expressions don't have visbility into public variables at the same scope.
// However fast-path expressions use the parent's ActivityInstance instead of
// creating their own, so we need to give them a DataContext without variables
bool includeLocalVariables = !this.instance.IsResolvingArguments;
if (this.instance.DataContext == null ||
this.instance.DataContext.IncludesLocalVariables != includeLocalVariables)
{
this.instance.DataContext
= new WorkflowDataContext(this.executor, this.instance, includeLocalVariables);
}
return this.instance.DataContext;
}
}
internal bool IsDisposed
{
get
{
return this.isDisposed;
}
}
public T GetExtension<T>()
where T : class
{
ThrowIfDisposed();
return this.executor.GetExtension<T>();
}
internal Location GetIgnorableResultLocation(RuntimeArgument resultArgument)
{
return this.executor.GetIgnorableResultLocation(resultArgument);
}
internal void Reinitialize(ActivityInstance instance, ActivityExecutor executor)
{
Reinitialize(instance, executor, instance.Activity, instance.InternalId);
}
internal void Reinitialize(ActivityInstance instance, ActivityExecutor executor, Activity activity, long instanceId)
{
this.isDisposed = false;
this.instance = instance;
this.executor = executor;
this.Activity = activity;
this.instanceId = instanceId;
}
// extra insurance against misuse (if someone stashes away the execution context to use later)
internal void Dispose()
{
this.isDisposed = true;
this.instance = null;
this.executor = null;
this.Activity = null;
this.instanceId = 0;
}
internal void DisposeDataContext()
{
if (this.instance.DataContext != null)
{
this.instance.DataContext.DisposeEnvironment();
this.instance.DataContext = null;
}
}
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
public Location<T> GetLocation<T>(LocationReference locationReference)
{
ThrowIfDisposed();
if (locationReference == null)
{
throw FxTrace.Exception.ArgumentNull("locationReference");
}
Location location = locationReference.GetLocation(this);
Location<T> typedLocation = location as Location<T>;
if (typedLocation != null)
{
return typedLocation;
}
else
{
Fx.Assert(location != null, "The contract of LocationReference is that GetLocation never returns null.");
if (locationReference.Type == typeof(T))
{
return new TypedLocationWrapper<T>(location);
}
else
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.LocationTypeMismatch(locationReference.Name, typeof(T), locationReference.Type)));
}
}
}
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
public T GetValue<T>(LocationReference locationReference)
{
ThrowIfDisposed();
if (locationReference == null)
{
throw FxTrace.Exception.ArgumentNull("locationReference");
}
return GetValueCore<T>(locationReference);
}
internal T GetValueCore<T>(LocationReference locationReference)
{
Location location = locationReference.GetLocationForRead(this);
Location<T> typedLocation = location as Location<T>;
if (typedLocation != null)
{
// If we hit this path we can avoid boxing value types
return typedLocation.Value;
}
else
{
Fx.Assert(location != null, "The contract of LocationReference is that GetLocation never returns null.");
return TypeHelper.Convert<T>(location.Value);
}
}
public void SetValue<T>(LocationReference locationReference, T value)
{
ThrowIfDisposed();
if (locationReference == null)
{
throw FxTrace.Exception.ArgumentNull("locationReference");
}
SetValueCore<T>(locationReference, value);
}
internal void SetValueCore<T>(LocationReference locationReference, T value)
{
Location location = locationReference.GetLocationForWrite(this);
Location<T> typedLocation = location as Location<T>;
if (typedLocation != null)
{
// If we hit this path we can avoid boxing value types
typedLocation.Value = value;
}
else
{
if (!TypeHelper.AreTypesCompatible(value, locationReference.Type))
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.CannotSetValueToLocation(value != null ? value.GetType() : typeof(T), locationReference.Name, locationReference.Type)));
}
location.Value = value;
}
}
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
[SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters,
Justification = "Generic needed for type inference")]
public T GetValue<T>(OutArgument<T> argument)
{
ThrowIfDisposed();
if (argument == null)
{
throw FxTrace.Exception.ArgumentNull("argument");
}
argument.ThrowIfNotInTree();
return GetValueCore<T>(argument.RuntimeArgument);
}
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
[SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters,
Justification = "Generic needed for type inference")]
public T GetValue<T>(InOutArgument<T> argument)
{
ThrowIfDisposed();
if (argument == null)
{
throw FxTrace.Exception.ArgumentNull("argument");
}
argument.ThrowIfNotInTree();
return GetValueCore<T>(argument.RuntimeArgument);
}
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
[SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters,
Justification = "Generic needed for type inference")]
public T GetValue<T>(InArgument<T> argument)
{
ThrowIfDisposed();
if (argument == null)
{
throw FxTrace.Exception.ArgumentNull("argument");
}
argument.ThrowIfNotInTree();
return GetValueCore<T>(argument.RuntimeArgument);
}
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
public object GetValue(Argument argument)
{
ThrowIfDisposed();
if (argument == null)
{
throw FxTrace.Exception.ArgumentNull("argument");
}
argument.ThrowIfNotInTree();
return GetValueCore<object>(argument.RuntimeArgument);
}
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
[SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters,
Justification = "We explicitly provide a RuntimeArgument overload to avoid requiring the object type parameter.")]
public object GetValue(RuntimeArgument runtimeArgument)
{
ThrowIfDisposed();
if (runtimeArgument == null)
{
throw FxTrace.Exception.ArgumentNull("runtimeArgument");
}
return GetValueCore<object>(runtimeArgument);
}
[SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters,
Justification = "Generic needed for type inference")]
public void SetValue<T>(OutArgument<T> argument, T value)
{
ThrowIfDisposed();
if (argument == null)
{
// We want to shortcut if the argument is null
return;
}
argument.ThrowIfNotInTree();
SetValueCore(argument.RuntimeArgument, value);
}
[SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters,
Justification = "Generic needed for type inference")]
public void SetValue<T>(InOutArgument<T> argument, T value)
{
ThrowIfDisposed();
if (argument == null)
{
// We want to shortcut if the argument is null
return;
}
argument.ThrowIfNotInTree();
SetValueCore(argument.RuntimeArgument, value);
}
[SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters,
Justification = "Generic needed for type inference")]
public void SetValue<T>(InArgument<T> argument, T value)
{
ThrowIfDisposed();
if (argument == null)
{
// We want to shortcut if the argument is null
return;
}
argument.ThrowIfNotInTree();
SetValueCore(argument.RuntimeArgument, value);
}
public void SetValue(Argument argument, object value)
{
ThrowIfDisposed();
if (argument == null)
{
throw FxTrace.Exception.ArgumentNull("argument");
}
argument.ThrowIfNotInTree();
SetValueCore(argument.RuntimeArgument, value);
}
internal void TrackCore(CustomTrackingRecord record)
{
Fx.Assert(!this.isDisposed, "not usable if disposed");
Fx.Assert(record != null, "expect non-null record");
if (this.executor.ShouldTrack)
{
record.Activity = new ActivityInfo(this.instance);
record.InstanceId = this.WorkflowInstanceId;
this.executor.AddTrackingRecord(record);
}
}
internal void ThrowIfDisposed()
{
if (this.isDisposed)
{
throw FxTrace.Exception.AsError(
new ObjectDisposedException(this.GetType().FullName, SR.AECDisposed));
}
}
}
}

View File

@@ -0,0 +1,26 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System.Runtime;
using System.Threading;
using System.Security;
static class ActivityDefaults
{
public static TimeSpan AcquireLockTimeout = TimeSpan.FromSeconds(30);
public static TimeSpan AsyncOperationContextCompleteTimeout = TimeSpan.FromSeconds(30);
public static TimeSpan CloseTimeout = TimeSpan.FromSeconds(30);
public static TimeSpan DeleteTimeout = TimeSpan.FromSeconds(30);
public static TimeSpan InvokeTimeout = TimeSpan.MaxValue;
public static TimeSpan LoadTimeout = TimeSpan.FromSeconds(30);
public static TimeSpan OpenTimeout = TimeSpan.FromSeconds(30);
public static TimeSpan ResumeBookmarkTimeout = TimeSpan.FromSeconds(30);
public static TimeSpan SaveTimeout = TimeSpan.FromSeconds(30);
public static TimeSpan InternalSaveTimeout = TimeSpan.MaxValue;
public static TimeSpan TrackingTimeout = TimeSpan.FromSeconds(30);
public static TimeSpan TransactionCompletionTimeout = TimeSpan.FromSeconds(30);
}
}

View File

@@ -0,0 +1,274 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System.Activities.Validation;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.Windows.Markup;
using System.Collections.ObjectModel;
[SuppressMessage(FxCop.Category.Naming, FxCop.Rule.IdentifiersShouldNotHaveIncorrectSuffix,
Justification = "Part of the sanctioned, public WF OM")]
[ContentProperty("Handler")]
public abstract class ActivityDelegate
{
internal static string ArgumentName = "Argument";
internal static string Argument1Name = "Argument1";
internal static string Argument2Name = "Argument2";
internal static string Argument3Name = "Argument3";
internal static string Argument4Name = "Argument4";
internal static string Argument5Name = "Argument5";
internal static string Argument6Name = "Argument6";
internal static string Argument7Name = "Argument7";
internal static string Argument8Name = "Argument8";
internal static string Argument9Name = "Argument9";
internal static string Argument10Name = "Argument10";
internal static string Argument11Name = "Argument11";
internal static string Argument12Name = "Argument12";
internal static string Argument13Name = "Argument13";
internal static string Argument14Name = "Argument14";
internal static string Argument15Name = "Argument15";
internal static string Argument16Name = "Argument16";
internal static string ResultArgumentName = "Result";
Activity owner;
bool isDisplayNameSet;
string displayName;
IList<RuntimeDelegateArgument> delegateParameters;
int cacheId;
ActivityCollectionType parentCollectionType;
protected ActivityDelegate()
{
}
public string DisplayName
{
get
{
if (string.IsNullOrEmpty(this.displayName))
{
this.displayName = this.GetType().Name;
}
return this.displayName;
}
set
{
this.isDisplayNameSet = true;
this.displayName = value;
}
}
[DefaultValue(null)]
public Activity Handler
{
get;
set;
}
internal LocationReferenceEnvironment Environment
{
get;
set;
}
internal Activity Owner
{
get
{
return this.owner;
}
}
internal ActivityCollectionType ParentCollectionType
{
get
{
return this.parentCollectionType;
}
}
internal IList<RuntimeDelegateArgument> RuntimeDelegateArguments
{
get
{
if (this.delegateParameters != null)
{
return this.delegateParameters;
}
return new ReadOnlyCollection<RuntimeDelegateArgument>(InternalGetRuntimeDelegateArguments());
}
}
protected internal virtual DelegateOutArgument GetResultArgument()
{
return null;
}
protected virtual void OnGetRuntimeDelegateArguments(IList<RuntimeDelegateArgument> runtimeDelegateArguments)
{
foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(this))
{
ArgumentDirection direction;
Type innerType;
if (ActivityUtilities.TryGetDelegateArgumentDirectionAndType(propertyDescriptor.PropertyType, out direction, out innerType))
{
runtimeDelegateArguments.Add(new RuntimeDelegateArgument(propertyDescriptor.Name, innerType, direction, (DelegateArgument)propertyDescriptor.GetValue(this)));
}
}
}
internal virtual IList<RuntimeDelegateArgument> InternalGetRuntimeDelegateArguments()
{
IList<RuntimeDelegateArgument> result = new List<RuntimeDelegateArgument>();
OnGetRuntimeDelegateArguments(result);
return result;
}
internal void InternalCacheMetadata()
{
this.delegateParameters = new ReadOnlyCollection<RuntimeDelegateArgument>(InternalGetRuntimeDelegateArguments());
}
internal bool CanBeScheduledBy(Activity parent)
{
// fast path if we're the sole (or first) child
if (object.ReferenceEquals(parent, this.owner))
{
return this.parentCollectionType != ActivityCollectionType.Imports;
}
else
{
return parent.Delegates.Contains(this) || parent.ImplementationDelegates.Contains(this);
}
}
internal bool InitializeRelationship(Activity parent, ActivityCollectionType collectionType, ref IList<ValidationError> validationErrors)
{
if (this.cacheId == parent.CacheId)
{
Fx.Assert(this.owner != null, "We must have set the owner when we set the cache ID");
// This means that we've already encountered a parent in the tree
// Validate that it is visible.
// In order to see the activity the new parent must be
// in the implementation IdSpace of an activity which has
// a public reference to it.
Activity referenceTarget = parent.MemberOf.Owner;
if (referenceTarget == null)
{
Activity handler = this.Handler;
if (handler == null)
{
ActivityUtilities.Add(ref validationErrors, new ValidationError(SR.ActivityDelegateCannotBeReferencedWithoutTargetNoHandler(parent.DisplayName, this.owner.DisplayName), false, parent));
}
else
{
ActivityUtilities.Add(ref validationErrors, new ValidationError(SR.ActivityDelegateCannotBeReferencedWithoutTarget(handler.DisplayName, parent.DisplayName, this.owner.DisplayName), false, parent));
}
return false;
}
else if (!referenceTarget.Delegates.Contains(this) && !referenceTarget.ImportedDelegates.Contains(this))
{
Activity handler = this.Handler;
if (handler == null)
{
ActivityUtilities.Add(ref validationErrors, new ValidationError(SR.ActivityDelegateCannotBeReferencedNoHandler(parent.DisplayName, referenceTarget.DisplayName, this.owner.DisplayName), false, parent));
}
else
{
ActivityUtilities.Add(ref validationErrors, new ValidationError(SR.ActivityDelegateCannotBeReferenced(handler.DisplayName, parent.DisplayName, referenceTarget.DisplayName, this.owner.DisplayName), false, parent));
}
return false;
}
// This is a valid reference so we want to allow
// normal processing to proceed.
return true;
}
this.owner = parent;
this.cacheId = parent.CacheId;
this.parentCollectionType = collectionType;
InternalCacheMetadata();
// We need to setup the delegate environment so that it is
// available when we process the Handler.
LocationReferenceEnvironment delegateEnvironment = null;
if (collectionType == ActivityCollectionType.Implementation)
{
delegateEnvironment = parent.ImplementationEnvironment;
}
else
{
delegateEnvironment = parent.PublicEnvironment;
}
if (this.RuntimeDelegateArguments.Count > 0)
{
ActivityLocationReferenceEnvironment newEnvironment = new ActivityLocationReferenceEnvironment(delegateEnvironment);
delegateEnvironment = newEnvironment;
for (int argumentIndex = 0; argumentIndex < this.RuntimeDelegateArguments.Count; argumentIndex++)
{
RuntimeDelegateArgument runtimeDelegateArgument = this.RuntimeDelegateArguments[argumentIndex];
DelegateArgument delegateArgument = runtimeDelegateArgument.BoundArgument;
if (delegateArgument != null)
{
if (delegateArgument.Direction != runtimeDelegateArgument.Direction)
{
ActivityUtilities.Add(ref validationErrors, new ValidationError(SR.RuntimeDelegateArgumentDirectionIncorrect, parent));
}
if (delegateArgument.Type != runtimeDelegateArgument.Type)
{
ActivityUtilities.Add(ref validationErrors, new ValidationError(SR.RuntimeDelegateArgumentTypeIncorrect, parent));
}
// NOTE: We don't initialize this relationship here because
// at runtime we'll actually just place these variables in the
// environment of the Handler. We'll initialize and set an
// ID when we process the Handler.
newEnvironment.Declare(delegateArgument, this.owner, ref validationErrors);
}
}
}
this.Environment = delegateEnvironment;
if (this.Handler != null)
{
return this.Handler.InitializeRelationship(this, collectionType, ref validationErrors);
}
return true;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeDisplayName()
{
return this.isDisplayNameSet;
}
public override string ToString()
{
return this.DisplayName;
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System.Runtime.Serialization;
using System.Runtime;
[DataContract]
public enum ActivityInstanceState
{
[EnumMember]
Executing,
[EnumMember]
Closed,
[EnumMember]
Canceled,
[EnumMember]
Faulted,
// If any more states are added, ensure they are also added to ActivityInstanceStateExtension.GetStateName
}
internal static class ActivityInstanceStateExtension
{
internal static string GetStateName(this ActivityInstanceState state)
{
switch (state)
{
case ActivityInstanceState.Executing:
return "Executing";
case ActivityInstanceState.Closed:
return "Closed";
case ActivityInstanceState.Canceled:
return "Canceled";
case ActivityInstanceState.Faulted:
return "Faulted";
default:
Fx.Assert("Don't understand ActivityInstanceState named " + state.ToString());
return state.ToString();
}
}
}
}

View File

@@ -0,0 +1,214 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System.Activities.Validation;
using System.Collections.Generic;
using System.Runtime;
[Fx.Tag.XamlVisible(false)]
sealed class ActivityLocationReferenceEnvironment : LocationReferenceEnvironment
{
Dictionary<string, LocationReference> declarations;
List<LocationReference> unnamedDeclarations;
public ActivityLocationReferenceEnvironment()
{
}
public ActivityLocationReferenceEnvironment(LocationReferenceEnvironment parent)
{
this.Parent = parent;
if (this.Parent != null)
{
this.InternalRoot = parent.Root;
}
}
public override Activity Root
{
get
{
return this.InternalRoot;
}
}
public Activity InternalRoot
{
get;
set;
}
Dictionary<string, LocationReference> Declarations
{
get
{
if (this.declarations == null)
{
this.declarations = new Dictionary<string, LocationReference>();
}
return this.declarations;
}
}
public override bool IsVisible(LocationReference locationReference)
{
if (locationReference == null)
{
throw FxTrace.Exception.ArgumentNull("locationReference");
}
LocationReferenceEnvironment currentScope = this;
while (currentScope != null)
{
ActivityLocationReferenceEnvironment activityEnvironment = currentScope as ActivityLocationReferenceEnvironment;
if (activityEnvironment != null)
{
if (activityEnvironment.declarations != null)
{
foreach (LocationReference declaration in activityEnvironment.declarations.Values)
{
if (locationReference == declaration)
{
return true;
}
}
}
if (activityEnvironment.unnamedDeclarations != null)
{
for (int i = 0; i < activityEnvironment.unnamedDeclarations.Count; i++)
{
if (locationReference == activityEnvironment.unnamedDeclarations[i])
{
return true;
}
}
}
}
else
{
return currentScope.IsVisible(locationReference);
}
currentScope = currentScope.Parent;
}
return false;
}
public void Declare(LocationReference locationReference, Activity owner, ref IList<ValidationError> validationErrors)
{
Fx.Assert(locationReference != null, "Must not be null");
if (locationReference.Name == null)
{
if (this.unnamedDeclarations == null)
{
this.unnamedDeclarations = new List<LocationReference>();
}
this.unnamedDeclarations.Add(locationReference);
}
else
{
if (this.Declarations.ContainsKey(locationReference.Name))
{
string id = null;
if (owner != null)
{
id = owner.Id;
}
ValidationError validationError = new ValidationError(SR.SymbolNamesMustBeUnique(locationReference.Name))
{
Source = owner,
Id = id
};
ActivityUtilities.Add(ref validationErrors, validationError);
}
else
{
this.Declarations.Add(locationReference.Name, locationReference);
}
}
}
public override bool TryGetLocationReference(string name, out LocationReference result)
{
if (name == null)
{
// We don't allow null names in our LocationReferenceEnvironment but
// a custom declared environment might. We need to walk up
// to the root and see if it chains to a
// non-ActivityLocationReferenceEnvironment implementation
LocationReferenceEnvironment currentEnvironment = this.Parent;
while (currentEnvironment is ActivityLocationReferenceEnvironment)
{
currentEnvironment = currentEnvironment.Parent;
}
if (currentEnvironment != null)
{
Fx.Assert(!(currentEnvironment is ActivityLocationReferenceEnvironment), "We must be at a non-ActivityLocationReferenceEnvironment implementation.");
return currentEnvironment.TryGetLocationReference(name, out result);
}
}
else
{
if (this.declarations != null && this.declarations.TryGetValue(name, out result))
{
return true;
}
bool found = false;
LocationReferenceEnvironment currentEnvironment = this.Parent;
LocationReferenceEnvironment rootEnvironment = this;
// Loop through all of the ActivityLocationReferenceEnvironments we have chained together
while (currentEnvironment != null && currentEnvironment is ActivityLocationReferenceEnvironment)
{
ActivityLocationReferenceEnvironment activityEnvironment = (ActivityLocationReferenceEnvironment)currentEnvironment;
if (activityEnvironment.declarations != null && activityEnvironment.declarations.TryGetValue(name, out result))
{
return true;
}
rootEnvironment = currentEnvironment;
currentEnvironment = currentEnvironment.Parent;
}
if (!found)
{
if (currentEnvironment != null)
{
// Looks like we have a non-ActivityLocationReferenceEnvironment at the root
Fx.Assert(!(currentEnvironment is ActivityLocationReferenceEnvironment), "We should have some other host environment at this point.");
if (currentEnvironment.TryGetLocationReference(name, out result))
{
return true;
}
}
}
}
result = null;
return false;
}
public override IEnumerable<LocationReference> GetLocationReferences()
{
return this.Declarations.Values;
}
}
}

View File

@@ -0,0 +1,295 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Activities
{
using System;
using System.Runtime;
using System.Collections.ObjectModel;
using System.Activities.Validation;
public struct ActivityMetadata
{
Activity activity;
LocationReferenceEnvironment environment;
bool createEmptyBindings;
internal ActivityMetadata(Activity activity, LocationReferenceEnvironment environment, bool createEmptyBindings)
{
this.activity = activity;
this.environment = environment;
this.createEmptyBindings = createEmptyBindings;
}
internal bool CreateEmptyBindings
{
get
{
return this.createEmptyBindings;
}
}
public LocationReferenceEnvironment Environment
{
get
{
return this.environment;
}
}
public bool HasViolations
{
get
{
if (this.activity == null)
{
return false;
}
else
{
return this.activity.HasTempViolations;
}
}
}
public override bool Equals(object obj)
{
if (!(obj is ActivityMetadata))
{
return false;
}
ActivityMetadata other = (ActivityMetadata)obj;
return other.activity == this.activity && other.Environment == this.Environment
&& other.CreateEmptyBindings == this.CreateEmptyBindings;
}
public override int GetHashCode()
{
if (this.activity == null)
{
return 0;
}
else
{
return this.activity.GetHashCode();
}
}
public static bool operator ==(ActivityMetadata left, ActivityMetadata right)
{
return left.Equals(right);
}
public static bool operator !=(ActivityMetadata left, ActivityMetadata right)
{
return !left.Equals(right);
}
public void Bind(Argument binding, RuntimeArgument argument)
{
ThrowIfDisposed();
Argument.TryBind(binding, argument, this.activity);
}
public void SetValidationErrorsCollection(Collection<ValidationError> validationErrors)
{
ThrowIfDisposed();
ActivityUtilities.RemoveNulls(validationErrors);
this.activity.SetTempValidationErrorCollection(validationErrors);
}
public void AddValidationError(string validationErrorMessage)
{
AddValidationError(new ValidationError(validationErrorMessage));
}
public void AddValidationError(ValidationError validationError)
{
ThrowIfDisposed();
if (validationError != null)
{
this.activity.AddTempValidationError(validationError);
}
}
public void SetArgumentsCollection(Collection<RuntimeArgument> arguments)
{
ThrowIfDisposed();
ActivityUtilities.RemoveNulls(arguments);
this.activity.SetArgumentsCollection(arguments, this.createEmptyBindings);
}
public void AddArgument(RuntimeArgument argument)
{
ThrowIfDisposed();
if (argument != null)
{
this.activity.AddArgument(argument, this.createEmptyBindings);
}
}
public void SetImportedChildrenCollection(Collection<Activity> importedChildren)
{
ThrowIfDisposed();
ActivityUtilities.RemoveNulls(importedChildren);
this.activity.SetImportedChildrenCollection(importedChildren);
}
public void AddImportedChild(Activity importedChild)
{
AddImportedChild(importedChild, null);
}
public void AddImportedChild(Activity importedChild, object origin)
{
ThrowIfDisposed();
ActivityUtilities.ValidateOrigin(origin, this.activity);
if (importedChild != null)
{
this.activity.AddImportedChild(importedChild);
if (importedChild.CacheId != this.activity.CacheId)
{
importedChild.Origin = origin;
}
}
}
public void SetImportedDelegatesCollection(Collection<ActivityDelegate> importedDelegates)
{
ThrowIfDisposed();
ActivityUtilities.RemoveNulls(importedDelegates);
this.activity.SetImportedDelegatesCollection(importedDelegates);
}
public void AddImportedDelegate(ActivityDelegate importedDelegate)
{
AddImportedDelegate(importedDelegate, null);
}
public void AddImportedDelegate(ActivityDelegate importedDelegate, object origin)
{
ThrowIfDisposed();
ActivityUtilities.ValidateOrigin(origin, this.activity);
if (importedDelegate != null)
{
this.activity.AddImportedDelegate(importedDelegate);
if (importedDelegate.Handler != null && importedDelegate.Handler.CacheId != this.activity.CacheId)
{
importedDelegate.Handler.Origin = origin;
}
// We don't currently have ActivityDelegate.Origin. If we ever add it, or if we ever
// expose Origin publicly, we need to also set it here.
}
}
public void SetVariablesCollection(Collection<Variable> variables)
{
ThrowIfDisposed();
ActivityUtilities.RemoveNulls(variables);
this.activity.SetVariablesCollection(variables);
}
public void AddVariable(Variable variable)
{
AddVariable(variable, null);
}
public void AddVariable(Variable variable, object origin)
{
ThrowIfDisposed();
ActivityUtilities.ValidateOrigin(origin, this.activity);
if (variable != null)
{
this.activity.AddVariable(variable);
if (variable.CacheId != this.activity.CacheId)
{
variable.Origin = origin;
if (variable.Default != null && variable.Default.CacheId != this.activity.CacheId)
{
variable.Default.Origin = origin;
}
}
}
}
public Collection<RuntimeArgument> GetArgumentsWithReflection()
{
return Activity.ReflectedInformation.GetArguments(this.activity);
}
public Collection<Activity> GetImportedChildrenWithReflection()
{
return Activity.ReflectedInformation.GetChildren(this.activity);
}
public Collection<Variable> GetVariablesWithReflection()
{
return Activity.ReflectedInformation.GetVariables(this.activity);
}
public Collection<ActivityDelegate> GetImportedDelegatesWithReflection()
{
return Activity.ReflectedInformation.GetDelegates(this.activity);
}
public void AddDefaultExtensionProvider<T>(Func<T> extensionProvider)
where T : class
{
if (extensionProvider == null)
{
throw FxTrace.Exception.ArgumentNull("extensionProvider");
}
this.activity.AddDefaultExtensionProvider(extensionProvider);
}
public void RequireExtension<T>()
where T : class
{
this.activity.RequireExtension(typeof(T));
}
public void RequireExtension(Type extensionType)
{
if (extensionType == null)
{
throw FxTrace.Exception.ArgumentNull("extensionType");
}
if (extensionType.IsValueType)
{
throw FxTrace.Exception.Argument("extensionType", SR.RequireExtensionOnlyAcceptsReferenceTypes(extensionType.FullName));
}
this.activity.RequireExtension(extensionType);
}
internal void Dispose()
{
this.activity = null;
}
void ThrowIfDisposed()
{
if (this.activity == null)
{
throw FxTrace.Exception.AsError(new ObjectDisposedException(ToString()));
}
}
}
}

View File

@@ -0,0 +1,25 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.Activities
{
public class ActivityPropertyReference
{
public ActivityPropertyReference()
{
}
public string SourceProperty
{
get;
set;
}
public string TargetProperty
{
get;
set;
}
}
}

View File

@@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System.Runtime.Serialization;
public abstract class ActivityWithResult : Activity
{
internal ActivityWithResult()
: base()
{
}
public Type ResultType
{
get
{
return this.InternalResultType;
}
}
[IgnoreDataMember] // this member is repeated by all subclasses, which we control
public OutArgument Result
{
get
{
return this.ResultCore;
}
set
{
this.ResultCore = value;
}
}
internal abstract Type InternalResultType
{
get;
}
internal abstract OutArgument ResultCore
{
get;
set;
}
internal RuntimeArgument ResultRuntimeArgument
{
get;
set;
}
internal abstract object InternalExecuteInResolutionContextUntyped(CodeActivityContext resolutionContext);
internal override bool IsActivityWithResult
{
get
{
return true;
}
}
}
}

View File

@@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System.Collections.Generic;
using System.Runtime;
// This wrapper is used to make our "new Expression" and "new Default" APIs
// work correctly even if the expression set on the base class doesn't
// match. We'll log the error at cache metadata time.
class ActivityWithResultWrapper<T> : CodeActivity<T>, Argument.IExpressionWrapper
{
ActivityWithResult expression;
public ActivityWithResultWrapper(ActivityWithResult expression)
{
this.expression = expression;
}
ActivityWithResult Argument.IExpressionWrapper.InnerExpression
{
get
{
return this.expression;
}
}
protected override void CacheMetadata(CodeActivityMetadata metadata)
{
// If we've gotten here then argument validation has already
// logged a validation error.
}
protected override T Execute(CodeActivityContext context)
{
Fx.Assert("We'll never get here!");
return default(T);
}
}
}

View File

@@ -0,0 +1,344 @@
//-----------------------------------------------------------------------------
// 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.Generic;
using System.ComponentModel;
using System.Runtime;
using System.Runtime.Serialization;
using System.Windows.Markup;
public abstract class Argument
{
public static readonly int UnspecifiedEvaluationOrder = -1;
public const string ResultValue = "Result";
ArgumentDirection direction;
RuntimeArgument runtimeArgument;
int evaluationOrder;
internal Argument()
{
this.evaluationOrder = Argument.UnspecifiedEvaluationOrder;
}
public Type ArgumentType
{
get;
internal set;
}
public ArgumentDirection Direction
{
get
{
return this.direction;
}
internal set
{
ArgumentDirectionHelper.Validate(value, "value");
this.direction = value;
}
}
[DefaultValue(-1)]
public int EvaluationOrder
{
get
{
return this.evaluationOrder;
}
set
{
if (value < 0 && value != Argument.UnspecifiedEvaluationOrder)
{
throw FxTrace.Exception.ArgumentOutOfRange("EvaluationOrder", value, SR.InvalidEvaluationOrderValue);
}
this.evaluationOrder = value;
}
}
[IgnoreDataMember] // this member is repeated by all subclasses, which we control
[DefaultValue(null)]
public ActivityWithResult Expression
{
get
{
return this.ExpressionCore;
}
set
{
this.ExpressionCore = value;
}
}
internal abstract ActivityWithResult ExpressionCore
{
get;
set;
}
internal RuntimeArgument RuntimeArgument
{
get
{
return this.runtimeArgument;
}
set
{
this.runtimeArgument = value;
}
}
internal bool IsInTree
{
get
{
return (this.runtimeArgument != null && this.runtimeArgument.IsInTree);
}
}
internal bool WasDesignTimeNull
{
get;
set;
}
internal int Id
{
get
{
Fx.Assert(this.runtimeArgument != null, "We shouldn't call Id unless we have a runtime argument.");
return this.runtimeArgument.Id;
}
}
internal bool IsEmpty
{
get
{
return this.Expression == null;
}
}
public static Argument CreateReference(Argument argumentToReference, string referencedArgumentName)
{
if (argumentToReference == null)
{
throw FxTrace.Exception.ArgumentNull("argumentToReference");
}
if (string.IsNullOrEmpty(referencedArgumentName))
{
throw FxTrace.Exception.ArgumentNullOrEmpty("referencedArgumentName");
}
return ActivityUtilities.CreateReferenceArgument(argumentToReference.ArgumentType, argumentToReference.Direction, referencedArgumentName);
}
// for ArgumentValueSerializer
internal bool CanConvertToString(IValueSerializerContext context)
{
if (this.WasDesignTimeNull)
{
return true;
}
else
{
if (this.EvaluationOrder == Argument.UnspecifiedEvaluationOrder)
{
return ActivityWithResultValueSerializer.CanConvertToStringWrapper(this.Expression, context);
}
else
{
return false;
}
}
}
internal string ConvertToString(IValueSerializerContext context)
{
if (this.WasDesignTimeNull)
{
// this argument instance was artificially created by the runtime
// to Xaml, this should appear as {x:Null}
return null;
}
return ActivityWithResultValueSerializer.ConvertToStringWrapper(this.Expression, context);
}
internal static void Bind(Argument binding, RuntimeArgument argument)
{
if (binding != null)
{
Fx.Assert(binding.Direction == argument.Direction, "The directions must match.");
Fx.Assert(binding.ArgumentType == argument.Type, "The types must match.");
binding.RuntimeArgument = argument;
}
argument.BoundArgument = binding;
}
internal static void TryBind(Argument binding, RuntimeArgument argument, Activity violationOwner)
{
if (argument == null)
{
throw FxTrace.Exception.ArgumentNull("argument");
}
bool passedValidations = true;
if (binding != null)
{
if (binding.Direction != argument.Direction)
{
violationOwner.AddTempValidationError(new ValidationError(SR.ArgumentDirectionMismatch(argument.Name, argument.Direction, binding.Direction)));
passedValidations = false;
}
if (binding.ArgumentType != argument.Type)
{
violationOwner.AddTempValidationError(new ValidationError(SR.ArgumentTypeMismatch(argument.Name, argument.Type, binding.ArgumentType)));
passedValidations = false;
}
}
if (passedValidations)
{
Bind(binding, argument);
}
}
public static Argument Create(Type type, ArgumentDirection direction)
{
return ActivityUtilities.CreateArgument(type, direction);
}
internal abstract Location CreateDefaultLocation();
internal abstract void Declare(LocationEnvironment targetEnvironment, ActivityInstance activityInstance);
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
public object Get(ActivityContext context)
{
return Get<object>(context);
}
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
public T Get<T>(ActivityContext context)
{
if (context == null)
{
throw FxTrace.Exception.ArgumentNull("context");
}
ThrowIfNotInTree();
return context.GetValue<T>(this.RuntimeArgument);
}
public void Set(ActivityContext context, object value)
{
if (context == null)
{
throw FxTrace.Exception.ArgumentNull("context");
}
ThrowIfNotInTree();
context.SetValue(this.RuntimeArgument, value);
}
internal void Validate(Activity owner, ref IList<ValidationError> validationErrors)
{
if (this.Expression != null)
{
if (this.Expression.Result != null && !this.Expression.Result.IsEmpty)
{
ValidationError validationError = new ValidationError(SR.ResultCannotBeSetOnArgumentExpressions, false, this.RuntimeArgument.Name, owner);
ActivityUtilities.Add(ref validationErrors, validationError);
}
ActivityWithResult actualExpression = this.Expression;
if (actualExpression is IExpressionWrapper)
{
actualExpression = ((IExpressionWrapper)actualExpression).InnerExpression;
}
switch (this.Direction)
{
case ArgumentDirection.In:
if (actualExpression.ResultType != this.ArgumentType)
{
ActivityUtilities.Add(
ref validationErrors,
new ValidationError(SR.ArgumentValueExpressionTypeMismatch(this.ArgumentType, actualExpression.ResultType), false, this.RuntimeArgument.Name, owner));
}
break;
case ArgumentDirection.InOut:
case ArgumentDirection.Out:
Type locationType;
if (!ActivityUtilities.IsLocationGenericType(actualExpression.ResultType, out locationType) ||
locationType != this.ArgumentType)
{
Type expectedType = ActivityUtilities.CreateActivityWithResult(ActivityUtilities.CreateLocation(this.ArgumentType));
ActivityUtilities.Add(
ref validationErrors,
new ValidationError(SR.ArgumentLocationExpressionTypeMismatch(expectedType.FullName, actualExpression.GetType().FullName), false, this.RuntimeArgument.Name, owner));
}
break;
}
}
}
// optional "fast-path" for arguments that can be resolved synchronously
internal abstract bool TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor);
// Soft-Link: This method is referenced through reflection by
// ExpressionUtilities.TryRewriteLambdaExpression. Update that
// file if the signature changes.
public Location GetLocation(ActivityContext context)
{
if (context == null)
{
throw FxTrace.Exception.ArgumentNull("context");
}
ThrowIfNotInTree();
return this.runtimeArgument.GetLocation(context);
}
internal void ThrowIfNotInTree()
{
if (!this.IsInTree)
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.ArgumentNotInTree(this.ArgumentType)));
}
}
internal static Location<T> CreateLocation<T>()
{
return new Location<T>();
}
internal interface IExpressionWrapper
{
ActivityWithResult InnerExpression { get; }
}
}
}

View File

@@ -0,0 +1,15 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System;
public enum ArgumentDirection
{
In = 0,
Out,
InOut,
}
}

View File

@@ -0,0 +1,46 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities
{
using System;
using System.ComponentModel;
static class ArgumentDirectionHelper
{
internal static bool IsDefined(ArgumentDirection direction)
{
return (direction == ArgumentDirection.In || direction == ArgumentDirection.Out || direction == ArgumentDirection.InOut);
}
public static void Validate(ArgumentDirection direction, string argumentName)
{
if (!IsDefined(direction))
{
throw FxTrace.Exception.AsError(
new InvalidEnumArgumentException(argumentName, (int)direction, typeof(ArgumentDirection)));
}
}
public static bool IsIn(Argument argument)
{
return ArgumentDirectionHelper.IsIn(argument.Direction);
}
public static bool IsIn(ArgumentDirection direction)
{
return (direction == ArgumentDirection.In) || (direction == ArgumentDirection.InOut);
}
public static bool IsOut(Argument argument)
{
return ArgumentDirectionHelper.IsOut(argument.Direction);
}
public static bool IsOut(ArgumentDirection direction)
{
return (direction == ArgumentDirection.Out) || (direction == ArgumentDirection.InOut);
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows.Markup;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("97bdccfe-43bf-4c17-991d-c797c2ef2243")]
// Define XAML namespace mappings
[assembly: XmlnsDefinition("http://schemas.microsoft.com/netfx/2009/xaml/activities", "System.Activities")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/netfx/2009/xaml/activities", "System.Activities.Statements")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/netfx/2009/xaml/activities", "System.Activities.Expressions")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/netfx/2009/xaml/activities", "System.Activities.Validation")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/netfx/2009/xaml/activities", "System.Activities.XamlIntegration")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger", "System.Activities.Debugger.Symbol")]
[assembly: XmlnsPrefix("http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger", "sads")]
// Friends Assembly
// TODO, 33059, Make common shim to access System.Activities's internal classes.
[assembly: InternalsVisibleTo("CDF.CIT.Scenarios.WorkflowModel.Debugger, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("CDF.CIT.Scenarios.WorkflowModel.Compensation, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("CDF.CIT.Scenarios.WorkflowModel.DataModel, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("CDF.CIT.Scenarios.Activities.Statements.StateMachine, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("System.Compensation, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
// Need to provide InternalsVisibleTo System.Runtime.Serialization to allow serialization of internal DataContracts/DataMembers in partial trust.
[assembly: InternalsVisibleTo("System.Runtime.Serialization, PublicKey=00000000000000000400000000000000")]

Some files were not shown because too many files have changed in this diff Show More