/// <summary>
/// Attempt to parse a profile string into an instance of <see cref="NetPortableProfile"/>.
/// The profile string can be either ProfileXXX or sl4+net45+wp7
/// </summary>
public static NetPortableProfile Parse(string profileValue)
{
if (String.IsNullOrEmpty(profileValue))
{
throw new ArgumentNullException("profileValue");
}
// Previously, only the full "ProfileXXX" long .NET name could be used for this method.
// This was inconsistent with the way the "custom profile string" (like "sl4+net45+wp7")
// was supported in other places. By fixing the way the profile table indexes the cached
// profiles, we can now indeed access by either naming, so we don't need the old check
// for the string starting with "Profile".
var result = NetPortableProfileTable.GetProfile(profileValue);
if (result != null)
{
return(result);
}
if (profileValue.StartsWith("Profile", StringComparison.OrdinalIgnoreCase))
{
// This can happen if profileValue is an unrecognized profile, or
// for some rare cases, the Portable Profile files are missing on disk.
return(null);
}
VersionUtility.ValidatePortableFrameworkProfilePart(profileValue);
var supportedFrameworks = profileValue.Split(new [] { '+' }, StringSplitOptions.RemoveEmptyEntries)
.Select(VersionUtility.ParseFrameworkName);
return(new NetPortableProfile(profileValue, supportedFrameworks));
}