/// <summary> /// Adds messages and keys from the specified outcome. /// </summary> /// <param name="outcome">Source outcome that keys are pulled from.</param> public SuccessOutcomeBuilder <TValue> FromOutcome(IOutcome outcome) { WithMessage(outcome.Messages); WithKeysFrom(outcome); #if NET45 || NET40 //If outcome has a Value, and if we can coerce it into TValue, //we should do so. if (outcome.GetType().IsGenericType) //only generics have Value { //get the contents of value var value = outcome.GetType() .GetProperty("Value") .GetValue(outcome, null); if (value is TValue) //are these types compatibile? { WithValue((TValue)value); //if so, caste and assign. } } #endif #if NETSTANDARD1_3 //If outcome has a Value, and if we can coerce it into TValue, //we should do so. var type = outcome.GetType(); var info = type.GetTypeInfo(); if (info.IsGenericType) //only generics have Value { //get the contents of value var value = type .GetRuntimeProperty("Value") .GetValue(outcome, null); if (value is TValue) //are these types compatibile? { WithValue((TValue)value); //if so, caste and assign. } } #endif return(this); }