示例#1
0
        private void SetTypeAndVersion(string targetValue)
        {
            if (targetValue.StartsWith(TargetValuePrefix.Core, true, CultureInfo.InvariantCulture))
            {
                Type    = TargetType.Core;
                Version = targetValue.Substring(TargetValuePrefix.Core.Length);
                return;
            }

            if (targetValue.StartsWith(TargetValuePrefix.Standard, true, CultureInfo.InvariantCulture))
            {
                Type    = TargetType.Standard;
                Version = targetValue.Substring(TargetValuePrefix.Standard.Length);
                return;
            }

            if (targetValue.StartsWith(TargetValuePrefix.FrameworkNew, true, CultureInfo.InvariantCulture))
            {
                Type    = TargetType.Framework;
                Version = VersionNumberFormatter.Format(TargetValue.Substring(TargetValuePrefix.FrameworkNew.Length));
                return;
            }

            if (targetValue.StartsWith(TargetValuePrefix.FrameworkOld, true, CultureInfo.InvariantCulture))
            {
                Type    = TargetType.Framework;
                Version = targetValue.Substring(TargetValuePrefix.FrameworkOld.Length);
                return;
            }

            throw new InvalidDotNetProjectException($"Could not determine {nameof(Type)} from '{targetValue}'.");
        }
        private void SetDescription()
        {
            switch (Type)
            {
            case TargetType.Framework:
                Description = _isOldStyleFormat ?
                              $".NET Framework {TargetValue.Substring(TargetValuePrefix.FrameworkOld.Length)}" :
                              $".NET Framework {VersionNumberFormatter.Format(TargetValue.Substring(TargetValuePrefix.FrameworkNew.Length))}";
                break;

            case TargetType.Core:
                Description = $".NET Core {TargetValue.Substring(TargetValuePrefix.Core.Length)}";
                break;

            case TargetType.Standard:
                Description = $".NET Standard {TargetValue.Substring(TargetValuePrefix.Standard.Length)}";
                break;

            default:
                throw new InvalidOperationException($"Unhandled {nameof(TargetType)}: {Type}.");
            }
        }