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));
        }
        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;
            }
        }
        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));
        }