/// <summary> /// Initializes a new instance of the <see cref="Framework"/> class. /// </summary> /// <param name="name">The framework namr.</param> /// <param name="type">The framework type.</param> /// <param name="major">The framework major version.</param> /// <param name="minor">The framework minor version.</param> /// <param name="moniker">The target framework moniker (TFM).</param> /// <param name="monikerMajor">The moniker major version.</param> /// <param name="monikerMinor">The moniker minor version.</param> public Framework(string name, FrameworkType type, int major, int minor, FrameworkMoniker moniker, int monikerMajor, int monikerMinor) { Name = name; Type = type; Major = major; Minor = minor; Moniker = moniker; MonikerMajor = monikerMajor; MonikerMinor = monikerMinor; }
private void ParseTargetFrameworkNetFramework(List <Framework> parsedFrameworkList, string frameworkName) { string FrameworkString = frameworkName; string MonikerString = string.Empty; FrameworkMoniker Moniker = FrameworkMoniker.none; foreach (FrameworkMoniker?MonikerValue in typeof(FrameworkMoniker).GetEnumValues()) { if (MonikerValue == null || MonikerValue == FrameworkMoniker.none) { continue; } string MonikerName = MonikerValue.Value.ToString(); int MonikerIndex = FrameworkString.IndexOf($"-{MonikerName}", StringComparison.InvariantCulture); if (MonikerIndex > 0) { Moniker = MonikerValue.Value; MonikerString = FrameworkString.Substring(MonikerIndex + 1); FrameworkString = FrameworkString.Substring(0, MonikerIndex); break; } } string FrameworkVersionString = FrameworkString.Substring(NetFrameworkPattern.Length); if (ParseNetVersion(FrameworkVersionString, out int Major, out int Minor)) { if (Moniker != FrameworkMoniker.none) { string MonikerVersionString = MonikerString.Substring(Moniker.ToString().Length); if (ParseMonikerVersion(MonikerVersionString, out int MonikerMajor, out int MonikerMinor)) { Framework NewFramework = new Framework(frameworkName, FrameworkType.NetFramework, Major, Minor, Moniker, MonikerMajor, MonikerMinor); parsedFrameworkList.Add(NewFramework); } else { Framework NewFramework = new Framework(frameworkName, FrameworkType.NetFramework, Major, Minor, Moniker); parsedFrameworkList.Add(NewFramework); } }