public static Activity <TResult> FromVariable(Variable variable) { Type type; if (variable == null) { throw FxTrace.Exception.ArgumentNull("variable"); } if (TypeHelper.AreTypesCompatible(variable.Type, typeof(TResult))) { return(new VariableValue <TResult> { Variable = variable }); } if (!ActivityUtilities.IsLocationGenericType(typeof(TResult), out type) || (type != variable.Type)) { throw FxTrace.Exception.Argument("variable", System.Activities.SR.ConvertVariableToValueExpressionFailed(variable.GetType().FullName, typeof(Activity <TResult>).FullName)); } return((Activity <TResult>)ActivityUtilities.CreateVariableReference(variable)); }