Beispiel #1
0
        // 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 Microsoft.CoreWf.Internals.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 Microsoft.CoreWf.Internals.FxTrace.Exception.AsError(new InvalidOperationException(SR.LocationTypeMismatch(locationReference.Name, typeof(T), locationReference.Type)));
                }
            }
        }
 private Location GetLocationCore(ActivityContext context)
 {
     try
     {
         context.AllowChainedEnvironmentAccess = true;
         return(_innerReference.GetLocation(context));
     }
     finally
     {
         context.AllowChainedEnvironmentAccess = false;
     }
 }