public MappableLocation(LocationReference locationOwner, Activity activity, System.Activities.ActivityInstance activityInstance, System.Activities.Location location)
 {
     this.Name = locationOwner.Name;
     this.OwnerDisplayName = activity.DisplayName;
     this.Location = location;
     this.MappingKeyName = string.Format(CultureInfo.InvariantCulture, "activity.{0}-{1}_{2}", new object[] { activity.Id, locationOwner.Id, activityInstance.Id });
 }
 public InlinedLocationReference(LocationReference innerReference, Activity validAccessor, ArgumentDirection accessDirection)
 {
     this.innerReference = innerReference;
     this.validAccessor = validAccessor;
     this.allowReads = accessDirection != ArgumentDirection.Out;
     this.allowWrites = accessDirection != ArgumentDirection.In;
 }
 public void Declare(LocationReference locationReference, Activity owner, ref IList<ValidationError> validationErrors)
 {
     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 data = new ValidationError(System.Activities.SR.SymbolNamesMustBeUnique(locationReference.Name)) {
             Source = owner,
             Id = id
         };
         ActivityUtilities.Add<ValidationError>(ref validationErrors, data);
     }
     else
     {
         this.Declarations.Add(locationReference.Name, locationReference);
     }
 }
 public void Register(Location location, Activity activity, LocationReference locationOwner, System.Activities.ActivityInstance activityInstance)
 {
     if (this.mappableLocations == null)
     {
         this.mappableLocations = new List<MappableLocation>();
     }
     this.mappableLocations.Add(new MappableLocation(locationOwner, activity, activityInstance, location));
 }
 public InlinedLocationReference(LocationReference innerReference, Activity validAccessor)
 {
     this.innerReference = innerReference;
     this.validAccessor = validAccessor;
     this.allowReads = true;
     this.allowWrites = true;
     this.allowGetLocation = true;
 }
 private void AddProperty(LocationReference reference, Dictionary<string, object> names, List<PropertyDescriptorImpl> propertyList)
 {
     if (!string.IsNullOrEmpty(reference.Name) && !names.ContainsKey(reference.Name))
     {
         names.Add(reference.Name, reference);
         PropertyDescriptorImpl item = new PropertyDescriptorImpl(reference);
         propertyList.Add(item);
         this.AddNotifyHandler(item);
     }
 }
 private void AddProperty(LocationReference reference, Dictionary <string, object> names, List <PropertyDescriptorImpl> propertyList)
 {
     if (!string.IsNullOrEmpty(reference.Name) && !names.ContainsKey(reference.Name))
     {
         names.Add(reference.Name, reference);
         PropertyDescriptorImpl item = new PropertyDescriptorImpl(reference);
         propertyList.Add(item);
         this.AddNotifyHandler(item);
     }
 }
        internal T GetValueCore <T>(LocationReference locationReference)
        {
            System.Activities.Location location = locationReference.GetLocation(this);
            Location <T> location2 = location as Location <T>;

            if (location2 != null)
            {
                return(location2.Value);
            }
            return(TypeHelper.Convert <T>(location.Value));
        }
        public bool TryGetReferenceToPublicLocation(LocationReference publicReference,
                                                    out LocationReference equivalentReference)
        {
            if (publicReference == null)
            {
                throw FxTrace.Exception.ArgumentNull("publicReference");
            }
            ThrowIfUninitialized();

            return(TryGetReferenceToPublicLocation(publicReference, false, out equivalentReference));
        }
        public bool TryGetAccessToPublicLocation(LocationReference publicLocation,
                                                 ArgumentDirection accessDirection, out LocationReference equivalentLocation)
        {
            if (publicLocation == null)
            {
                throw FxTrace.Exception.ArgumentNull("publicLocation");
            }
            ThrowIfUninitialized();

            return(TryGetAccessToPublicLocation(publicLocation, accessDirection, false, out equivalentLocation));
        }
        public bool TryGetAccessToPublicLocation(LocationReference publicLocation,
            ArgumentDirection accessDirection, out LocationReference equivalentLocation)
        {
            if (publicLocation == null)
            {
                throw FxTrace.Exception.ArgumentNull("publicLocation");
            }
            ThrowIfUninitialized();

            return TryGetAccessToPublicLocation(publicLocation, accessDirection, false, out equivalentLocation);
        }
Beispiel #12
0
        public void SetValue <T>(LocationReference locationReference, T value)
        {
            ThrowIfDisposed();

            if (locationReference == null)
            {
                throw FxTrace.Exception.ArgumentNull(nameof(locationReference));
            }

            SetValueCore <T>(locationReference, value);
        }
        public bool TryGetReferenceToPublicLocation(LocationReference publicReference,
            out LocationReference equivalentReference)
        {
            if (publicReference == null)
            {
                throw FxTrace.Exception.ArgumentNull("publicReference");
            }
            ThrowIfUninitialized();

            return TryGetReferenceToPublicLocation(publicReference, false, out equivalentReference);
        }
Beispiel #14
0
        // 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(nameof(locationReference));
            }

            return(GetValueCore <T>(locationReference));
        }
 internal bool TryGetInlinedLocationReference(LocationReference sourceReference, out LocationReference inlinedReference)
 {
     this.ThrowIfDisposed();
     if (this.Environment.IsVisible(sourceReference))
     {
         this.CreateArgument(sourceReference);
         inlinedReference = new InlinedLocationReference(sourceReference, this.activity);
         return(true);
     }
     inlinedReference = null;
     return(false);
 }
Beispiel #16
0
        /// <summary>
        /// Gets the value core.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="locationReference">The location reference.</param>
        /// <returns>T.</returns>
        internal T GetValueCore <T>(LocationReference locationReference)
        {
            var location = locationReference.GetLocationForRead(this);

            if (location is Location <T> typedLocation)
            {
                // 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 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 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);
        }
        internal void SetValueCore <T>(LocationReference locationReference, T value)
        {
            System.Activities.Location location = locationReference.GetLocation(this);
            Location <T> location2 = location as Location <T>;

            if (location2 != null)
            {
                location2.Value = value;
            }
            else
            {
                if (!TypeHelper.AreTypesCompatible(value, locationReference.Type))
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.CannotSetValueToLocation((value != null) ? value.GetType() : typeof(T), locationReference.Name, locationReference.Type)));
                }
                location.Value = value;
            }
        }
        // In 4.0 the expression type for publicly inspectable auto-generated arguments was
        // LocationReferenceValue<T>, whether the argument was actually used as an L-Value or R-Value.
        // We keep that for back-compat (useLocationReferenceValue == true), and only use the new
        // EnvironmentLocationValue/Reference classes for new activities.
        internal bool TryGetAccessToPublicLocation(LocationReference publicLocation,
                                                   ArgumentDirection accessDirection, bool useLocationReferenceValue, out LocationReference equivalentLocation)
        {
            Fx.Assert(!useLocationReferenceValue || this.ActivityMetadata.CurrentActivity.UseOldFastPath, "useLocationReferenceValue should only be used for back-compat");

            if (this.metadata.Environment.IsVisible(publicLocation))
            {
                if (!this.withoutArgument)
                {
                    CreateArgument(publicLocation, accessDirection, useLocationReferenceValue);
                }
                equivalentLocation = new InlinedLocationReference(publicLocation, this.metadata.CurrentActivity, accessDirection);
                return(true);
            }

            equivalentLocation = null;
            return(false);
        }
Beispiel #21
0
        /// <summary>
        /// Sets the value core.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="locationReference">The location reference.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="InvalidOperationException"></exception>
        internal void SetValueCore <T>(LocationReference locationReference, T value)
        {
            var location = locationReference.GetLocationForWrite(this);

            if (location is Location <T> typedLocation)
            {
                // 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;
            }
        }
        public Location <T> GetLocation <T>(LocationReference locationReference)
        {
            this.ThrowIfDisposed();
            if (locationReference == null)
            {
                throw FxTrace.Exception.ArgumentNull("locationReference");
            }
            System.Activities.Location innerLocation = locationReference.GetLocation(this);
            Location <T> location2 = innerLocation as Location <T>;

            if (location2 != null)
            {
                return(location2);
            }
            if (locationReference.Type != typeof(T))
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.LocationTypeMismatch(locationReference.Name, typeof(T), locationReference.Type)));
            }
            return(new TypedLocationWrapper <T>(innerLocation));
        }
Beispiel #23
0
 public override bool TryGetLocationReference(string name, out LocationReference result)
 {
     if (name == null)
     {
         LocationReferenceEnvironment parent = base.Parent;
         while (parent is ActivityLocationReferenceEnvironment)
         {
             parent = parent.Parent;
         }
         if (parent != null)
         {
             return(parent.TryGetLocationReference(name, out result));
         }
     }
     else
     {
         if ((this.declarations != null) && this.declarations.TryGetValue(name, out result))
         {
             return(true);
         }
         bool flag = false;
         LocationReferenceEnvironment environment2 = base.Parent;
         while ((environment2 != null) && (environment2 is ActivityLocationReferenceEnvironment))
         {
             ActivityLocationReferenceEnvironment environment3 = (ActivityLocationReferenceEnvironment)environment2;
             if ((environment3.declarations != null) && environment3.declarations.TryGetValue(name, out result))
             {
                 return(true);
             }
             environment2 = environment2.Parent;
         }
         if ((!flag && (environment2 != null)) && environment2.TryGetLocationReference(name, out result))
         {
             return(true);
         }
     }
     result = null;
     return(false);
 }
Beispiel #24
0
        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 IsVisible(LocationReference locationReference)
 {
     if (locationReference == null)
     {
         throw FxTrace.Exception.ArgumentNull("locationReference");
     }
     for (LocationReferenceEnvironment environment = this; environment != null; environment = environment.Parent)
     {
         ActivityLocationReferenceEnvironment environment2 = environment as ActivityLocationReferenceEnvironment;
         if (environment2 == null)
         {
             return environment.IsVisible(locationReference);
         }
         if (environment2.declarations != null)
         {
             foreach (LocationReference reference in environment2.declarations.Values)
             {
                 if (locationReference == reference)
                 {
                     return true;
                 }
             }
         }
         if (environment2.unnamedDeclarations != null)
         {
             for (int i = 0; i < environment2.unnamedDeclarations.Count; i++)
             {
                 if (locationReference == environment2.unnamedDeclarations[i])
                 {
                     return true;
                 }
             }
         }
     }
     return false;
 }
Beispiel #26
0
 public override bool IsVisible(LocationReference locationReference)
 {
     if (locationReference == null)
     {
         throw FxTrace.Exception.ArgumentNull("locationReference");
     }
     for (LocationReferenceEnvironment environment = this; environment != null; environment = environment.Parent)
     {
         ActivityLocationReferenceEnvironment environment2 = environment as ActivityLocationReferenceEnvironment;
         if (environment2 == null)
         {
             return(environment.IsVisible(locationReference));
         }
         if (environment2.declarations != null)
         {
             foreach (LocationReference reference in environment2.declarations.Values)
             {
                 if (locationReference == reference)
                 {
                     return(true);
                 }
             }
         }
         if (environment2.unnamedDeclarations != null)
         {
             for (int i = 0; i < environment2.unnamedDeclarations.Count; i++)
             {
                 if (locationReference == environment2.unnamedDeclarations[i])
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Beispiel #27
0
            // TODO 131998, We should support readonly LocationReferences.
            // bool isReadOnly;

            /// <summary>
            /// Initializes a new instance of the <see cref="PropertyDescriptorImpl"/> class.
            /// </summary>
            /// <param name="reference">The reference.</param>
            public PropertyDescriptorImpl(LocationReference reference)
                : base(reference.Name, Array.Empty <Attribute>()) => this.LocationReference = reference;
Beispiel #28
0
 public void SetValue <T> (LocationReference locationReference, T value)
 {
     throw new NotImplementedException();
 }
Beispiel #29
0
 public T GetValue <T> (LocationReference locationReference)
 {
     throw new NotImplementedException();
 }
        internal void CreateLocationArgument(LocationReference sourceReference, bool useLocationReferenceValue = false)
        {
            ActivityWithResult expression = ActivityUtilities.CreateLocationAccessExpression(sourceReference, true, useLocationReferenceValue);

            AddGeneratedArgument(expression.ResultType, ArgumentDirection.In, expression);
        }
 public abstract bool IsVisible(LocationReference locationReference);
 internal void CreateLocationArgument(LocationReference sourceReference, bool useLocationReferenceValue = false)
 {
     ActivityWithResult expression = ActivityUtilities.CreateLocationAccessExpression(sourceReference, true, useLocationReferenceValue);
     AddGeneratedArgument(expression.ResultType, ArgumentDirection.In, expression);
 }
 public InlinedLocationReference(LocationReference innerReference, Activity validAccessor)
 {
     this.innerReference = innerReference;
     this.validAccessor = validAccessor;
 }
        internal void CreateArgument(LocationReference sourceReference, ArgumentDirection accessDirection, bool useLocationReferenceValue = false)
        {
            var expression = ActivityUtilities.CreateLocationAccessExpression(sourceReference, accessDirection != ArgumentDirection.In, useLocationReferenceValue);

            AddGeneratedArgument(sourceReference.Type, accessDirection, expression);
        }
        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 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);
                }
            }
        }
Beispiel #37
0
 public abstract bool TryGetLocationReference(string name, out LocationReference result);
Beispiel #38
0
 public abstract bool IsVisible(LocationReference locationReference);
 public static ActivityWithResult CreateLocationReferenceValue(LocationReference locationReference)
 {
     return((ActivityWithResult)Activator.CreateInstance(locationReferenceValueType.MakeGenericType(new Type[] { locationReference.Type }), new object[] { locationReference }));
 }
Beispiel #40
0
        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 bool TryGetLocationReference(string name, out LocationReference result)
 {
     if (name == null)
     {
         LocationReferenceEnvironment parent = base.Parent;
         while (parent is ActivityLocationReferenceEnvironment)
         {
             parent = parent.Parent;
         }
         if (parent != null)
         {
             return parent.TryGetLocationReference(name, out result);
         }
     }
     else
     {
         if ((this.declarations != null) && this.declarations.TryGetValue(name, out result))
         {
             return true;
         }
         bool flag = false;
         LocationReferenceEnvironment environment2 = base.Parent;
         while ((environment2 != null) && (environment2 is ActivityLocationReferenceEnvironment))
         {
             ActivityLocationReferenceEnvironment environment3 = (ActivityLocationReferenceEnvironment) environment2;
             if ((environment3.declarations != null) && environment3.declarations.TryGetValue(name, out result))
             {
                 return true;
             }
             environment2 = environment2.Parent;
         }
         if ((!flag && (environment2 != null)) && environment2.TryGetLocationReference(name, out result))
         {
             return true;
         }
     }
     result = null;
     return false;
 }
 public abstract bool TryGetLocationReference(string name, out LocationReference result);
            //



            public PropertyDescriptorImpl(LocationReference reference)
                : base(reference.Name, new Attribute[0])
            {
                this.reference = reference;
            }
Beispiel #44
0
 public InlinedLocationReference(LocationReference innerReference, Activity validAccessor)
 {
     this.innerReference = innerReference;
     this.validAccessor  = validAccessor;
 }
Beispiel #45
0
 public Location <T> GetLocation <T> (LocationReference locationReference)
 {
     throw new NotImplementedException();
 }
        // In 4.0 the expression type for publicly inspectable auto-generated arguments was 
        // LocationReferenceValue<T>, whether the argument was actually used as an L-Value or R-Value.
        // We keep that for back-compat (useLocationReferenceValue == true), and only use the new
        // EnvironmentLocationValue/Reference classes for new activities.
        internal bool TryGetAccessToPublicLocation(LocationReference publicLocation,
            ArgumentDirection accessDirection, bool useLocationReferenceValue, out LocationReference equivalentLocation)
        {
            Fx.Assert(!useLocationReferenceValue || this.ActivityMetadata.CurrentActivity.UseOldFastPath, "useLocationReferenceValue should only be used for back-compat");

            if (this.metadata.Environment.IsVisible(publicLocation))
            {
                if (!this.withoutArgument)
                {
                    CreateArgument(publicLocation, accessDirection, useLocationReferenceValue);
                }                
                equivalentLocation = new InlinedLocationReference(publicLocation, this.metadata.CurrentActivity, accessDirection);
                return true;
            }

            equivalentLocation = null;
            return false;
        }
 public LocationReferenceValue(System.Activities.LocationReference locationReference)
 {
     this.locationReference = locationReference;
 }
            // 



            public PropertyDescriptorImpl(LocationReference reference)
                : base(reference.Name, new Attribute[0])
            {
                this.reference = reference;
            }
            public static ActivityWithResult CreateNewLocationAccessExpression(Type type, bool isReference, bool useLocationReferenceValue, LocationReference locationReference)
            {
                Dictionary <Type, ILocationReferenceExpression> lookupTable;
                object tableLock;

                if (useLocationReferenceValue)
                {
                    lookupTable = locationReferenceValueTypeDefinitions;
                    tableLock   = locationReferenceValueTypeDefinitionsLock;
                }
                else
                {
                    lookupTable = isReference ? environmentLocationReferenceTypeDefinitions : environmentLocationValueTypeDefinitions;
                    tableLock   = isReference ? environmentLocationReferenceTypeDefinitionsLock : environmentLocationValueTypeDefinitionsLock;
                }

                ILocationReferenceExpression existingInstance;

                lock (tableLock)
                {
                    if (!lookupTable.TryGetValue(type, out existingInstance))
                    {
                        var locationAccessExpressionType = CreateLocationAccessExpressionType(type, isReference, useLocationReferenceValue);

                        // Create an "empty" (locationReference = null) instance to put in the
                        // cache. This empty instance will only be used to create other instances,
                        // including the instance returned from this method. The cached instance
                        // will never be included in an activity tree, so the cached instance's
                        // rootActivity field will not be filled in and thus will not pin all the
                        // objects in the activity tree. The cached empty instance has a null
                        // locationReference because locationReference also pins parts of activity tree.
                        existingInstance = (ILocationReferenceExpression)Activator.CreateInstance(
                            locationAccessExpressionType, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { null }, null);

                        lookupTable[type] = existingInstance;
                    }
                }

                return(existingInstance.CreateNewInstance(locationReference));
            }