// 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(nameof(locationReference)); } Location location = locationReference.GetLocation(this); if (location is Location <T> typedLocation) { 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))); } } }
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)); }