コード例 #1
0
        public static bool Is(this Sdk sdk, SdkId id)
        {
            if (id.IsNull)
            {
                throw new ArgumentNullException(nameof(id));
            }

            return(sdk != null && sdk.Id == id);
        }
コード例 #2
0
        public static bool IsNot(this Sdk sdk, SdkId id)
        {
            if (id.IsNull)
            {
                throw new ArgumentNullException(nameof(id));
            }

            return(sdk == null || sdk.Id != id);
        }
コード例 #3
0
 public static Sdk FromEntryAssembly(
     SdkId id,
     string name    = null,
     string profile = null,
     string version = null)
 => new Sdk(
     id,
     new FrameworkName(Assembly
                       .GetEntryAssembly()
                       .GetCustomAttribute <TargetFrameworkAttribute> ()
                       .FrameworkName),
     Array.Empty <string> (),
     name,
     profile,
     version);
コード例 #4
0
        public Sdk(
            SdkId id,
            FrameworkName targetFramework,
            IEnumerable <string> assemblySearchPaths,
            string name    = null,
            string profile = null,
            string version = null)
        {
            Id = ((string)id)
                 ?? throw new ArgumentNullException(nameof(id));

            TargetFramework = targetFramework
                              ?? throw new ArgumentNullException(nameof(targetFramework));

            AssemblySearchPaths = assemblySearchPaths?.ToArray()
                                  ?? throw new ArgumentNullException(nameof(assemblySearchPaths));

            Name    = name;
            Profile = profile;
            Version = version;

            if (Name != null || Version != null)
            {
                return;
            }

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                Name = "System Mono";
                const string monoVersionPath = "/Library/Frameworks/Mono.framework/Versions/Current/VERSION";
                if (File.Exists(monoVersionPath))
                {
                    Version = File.ReadAllText(monoVersionPath)?.Trim();
                }
            }
            else
            {
                var versionInfo = FileVersionInfo.GetVersionInfo(typeof(object).Assembly.Location);
                Name    = ".NET Framework";
                Version = versionInfo.ProductVersion;
            }
        }