예제 #1
0
파일: Program.cs 프로젝트: Crae/rhiexec
        public static InstallerPhase ExecuteChildProcess(OSPlatform platform, string arguments, bool uploadErrors)
        {
            Logger.Log(LogLevel.Debug, "ExecuteChildProcess starting: " + platform + ", " + arguments);
              StringBuilder sb = new StringBuilder();
              Process p = new Process();

              string thisDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            #if DEBUG
              if (platform == OSPlatform.x86)
            p.StartInfo.FileName = Path.Combine(thisDir, @"..\..\x86\Debug\rhiexec.exe");
              else if (platform == OSPlatform.x64)
            p.StartInfo.FileName = Path.Combine(thisDir, @"..\..\x64\Debug\rhiexec.exe");
            #else
              if (platform == OSPlatform.x86)
            p.StartInfo.FileName = Path.Combine(thisDir, @"..\x86\rhiexec.exe");
              else if (platform == OSPlatform.x64)
            p.StartInfo.FileName = Path.Combine(thisDir, @"..\x64\rhiexec.exe");
            #endif

              sb.Append("/loglevel=").Append(m_options.LogLevel.ToString()).Append(" ");
              sb.Append("/logfile=\"").Append(Logger.LogFile).Append("\" ");
              if (m_options.SilentInstall)
              {
            sb.Append("/silent ");
            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            p.StartInfo.CreateNoWindow = true;
              }
              if (!uploadErrors)
            sb.Append("/noerrorreports ");
              sb.Append(arguments);

              p.StartInfo.Arguments = sb.ToString();
              p.StartInfo.UseShellExecute = false;

              Logger.Log(LogLevel.Debug, "Starting: " + p.StartInfo.FileName + " " + p.StartInfo.Arguments);
              if (!p.Start())
            return InstallerPhase.Unknown;

              // Fix for http://dev.mcneel.com/bugtrack/?q=68426
              // Add more time before cancelling operation
              int timeout = 10 * 60*1000; // 10 minutes
              p.WaitForExit(timeout);

              // Fix for http://dev.mcneel.com/bugtrack/?q=68426
              // Don't reference p.ExitCode property after calling p.Close - it crashes.
              int exitCode = 0;
              if (p.HasExited)
              {
            exitCode = p.ExitCode;
              }
              else
              {
            p.Close();
            Logger.Log(LogLevel.Warning, string.Format("Forcing closed after {0} seconds: {1}", timeout / 1000, p.StartInfo.FileName));
              }

              Logger.Log(LogLevel.Debug, "ExecuteChildProcess complete. Child process returned: " + (InstallerPhase)exitCode);
              return (InstallerPhase)exitCode;
        }
예제 #2
0
        public void CheckOSPlatform()
        {
            OSPlatform winObj = OSPlatform.Create("WINDOWS");
            OSPlatform winProp = OSPlatform.Windows;
            OSPlatform randomObj = OSPlatform.Create("random");
            OSPlatform defaultObj = default(OSPlatform);
            OSPlatform conObj = new OSPlatform();
            Assert.Throws<ArgumentNullException>(() => { OSPlatform nullObj = OSPlatform.Create(null); });
            Assert.Throws<ArgumentException>(() => { OSPlatform emptyObj = OSPlatform.Create(""); });

            Assert.True(winObj == winProp);
            Assert.True(winObj != randomObj);
            Assert.True(defaultObj == conObj);

            Assert.False(winObj == defaultObj);
            Assert.False(winObj == randomObj);
            Assert.False(winObj != winProp);

            Assert.True(winObj.Equals(winProp));
            Assert.True(conObj.Equals(defaultObj));

            Assert.False(defaultObj.Equals(winProp));
            Assert.False(winObj.Equals(null));
            Assert.False(winObj.Equals("something"));

            Assert.Equal("WINDOWS", winObj.ToString());
            Assert.Equal("WINDOWS", winProp.ToString());
            Assert.Equal("", defaultObj.ToString());
            Assert.Equal("", conObj.ToString());
            Assert.Equal("random", randomObj.ToString());

            Assert.Equal(winObj.GetHashCode(), winProp.GetHashCode());
            Assert.Equal(0, defaultObj.GetHashCode());
            Assert.Equal(defaultObj.GetHashCode(), conObj.GetHashCode());
        }
		private void CheckOSPlatforms( OSPlatform os, 
			string expectedPlatforms )
		{
			CheckPlatforms(
				new PlatformHelper( os, RuntimeFramework.CurrentFramework ),
				expectedPlatforms,
				PlatformHelper.OSPlatforms );
		}
예제 #4
0
        public static PreferenceStore GetStoreForPlatform(
            OSPlatform platform,
            Func <PreferenceStore> factory)
        {
            if (RuntimeInformation.IsOSPlatform(platform))
            {
                return(factory());
            }

            return(new MemoryOnlyPreferenceStore());
        }
예제 #5
0
        public static KeycodeAttribute GetKeycode(this Key key)
        {
            var enumType            = typeof(Key);
            var memberInfos         = enumType.GetMember(key.ToString());
            var enumValueMemberInfo = memberInfos.FirstOrDefault(m => m.DeclaringType == enumType);

            return(enumValueMemberInfo
                   .GetCustomAttributes(typeof(KeycodeAttribute), false)
                   .Cast <KeycodeAttribute>()
                   .First(k => RuntimeInformation.IsOSPlatform(OSPlatform.Create(k.Platform))));
        }
예제 #6
0
        public async Task TestExtractCoreRunLibAsync(string osPlatformStr, string expectedDllFilename)
        {
            var osPlatform = OSPlatform.Create(osPlatformStr);

            using var tempDir = _baseFixture.WithDisposableTempDirectory(_snapFilesystem);
            var expectedDllFilenameAbsolute = _snapFilesystem.PathCombine(tempDir.WorkingDirectory, expectedDllFilename);
            await _snapEmbeddedResources.ExtractCoreRunLibAsync(_snapFilesystem, _snapCryptoProvider, tempDir.WorkingDirectory, osPlatform);

            Assert.True(_snapFilesystem.FileExists(expectedDllFilenameAbsolute));
            Assert.True(_snapFilesystem.FileStat(expectedDllFilenameAbsolute).Length > 0);
        }
        public void Constructor_works(OSPlatform platform, Architecture processArchitecture)
        {
            // arrange

            // act
            var runtimeInformation = new RuntimeInformation(platform, processArchitecture);

            // assert
            _output.WriteLine(runtimeInformation.ToString());
            Assert.Equal(platform, runtimeInformation.Platform);
            Assert.Equal(processArchitecture, runtimeInformation.ProcessArchitecture);
        }
예제 #8
0
        public void TestGetCoreRunForSnapApp(string osPlatform, string appId, string expectedExeFilename)
        {
            var snapApp = _baseFixture.BuildSnapApp(appId);

            snapApp.Target.Os = OSPlatform.Create(osPlatform);

            var(memoryStream, coreRunFilename, coreRunOsPlatform) = _snapEmbeddedResources.GetCoreRunForSnapApp(snapApp, _snapFilesystem, _coreRunLibMock.Object);
            Assert.NotNull(memoryStream);
            Assert.True(memoryStream.Length > 0);
            Assert.Equal(expectedExeFilename, coreRunFilename);
            Assert.Equal(snapApp.Target.Os, coreRunOsPlatform);
        }
 /// <summary>
 /// Adds <see cref="IHxMessengerService"/> support to be able to add messages to HxMessenger.
 /// </summary>
 public static IServiceCollection AddHxMessenger(this IServiceCollection services)
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")))
     {
         // allows gRPC Interceptors and HttpMessageHandlers to pass error-messages to the HxMessenger without having to struggle with different DI Scope
         return(services.AddSingleton <IHxMessengerService, HxMessengerService>());
     }
     else
     {
         return(services.AddScoped <IHxMessengerService, HxMessengerService>());
     }
 }
예제 #10
0
 public static bool TestPlatformApplies(TestPlatforms platforms) =>
 (platforms.HasFlag(TestPlatforms.Any)) ||
 (platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) ||
 (platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ||
 (platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) ||
 (platforms.HasFlag(TestPlatforms.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ||
 (platforms.HasFlag(TestPlatforms.SunOS) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("SUNOS"))) ||
 (platforms.HasFlag(TestPlatforms.iOS) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS"))) ||
 (platforms.HasFlag(TestPlatforms.tvOS) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS"))) ||
 (platforms.HasFlag(TestPlatforms.Android) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID"))) ||
 (platforms.HasFlag(TestPlatforms.Browser) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER"))) ||
 (platforms.HasFlag(TestPlatforms.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
예제 #11
0
        public string GetOsPlatformDescription()
        {
            StringBuilder retval = new StringBuilder(1024);
            OSPlatform    os     = GetOSPlatform();

            retval.AppendLine($"OSPlatform: {os.ToString()}");
            retval.AppendLine($"RTI.FrameworkDescription: {RuntimeInformation.FrameworkDescription}");
            retval.AppendLine($"RTI.OSArchitecture: {RuntimeInformation.OSArchitecture}");
            retval.AppendLine($"RTI.OSDescription: {RuntimeInformation.OSDescription}");

            return(retval.ToString());
        }
예제 #12
0
        public CoreRunLib([JetBrains.Annotations.NotNull] ISnapFilesystem filesystem, OSPlatform osPlatform, [JetBrains.Annotations.NotNull] string workingDirectory)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }

            if (!osPlatform.IsSupportedOsVersion())
            {
                throw new PlatformNotSupportedException();
            }

            _osPlatform = osPlatform;

            var filename = filesystem.PathCombine(workingDirectory, "libcorerun-");

            #if SNAP_BOOTSTRAP
            return;
            #endif

            var rid = osPlatform.BuildRid();
            if (osPlatform == OSPlatform.Windows)
            {
                filename += $"{rid}.dll";
                _libPtr   = NativeMethodsWindows.dlopen(filename);
            }
            else if (osPlatform == OSPlatform.Linux)
            {
                filename += $"{rid}.so";
                _libPtr   = NativeMethodsUnix.dlopen(filename, NativeMethodsUnix.libdl_RTLD_NOW | NativeMethodsUnix.libdl_RTLD_LOCAL);
            }

            if (_libPtr == IntPtr.Zero)
            {
                throw new FileNotFoundException($"Failed to load corerun: {filename}. " +
                                                $"OS: {osPlatform}. " +
                                                $"64-bit OS: {Environment.Is64BitOperatingSystem}. " +
                                                $"Last error: {Marshal.GetLastWin32Error()}.");
            }

            // generic
            pal_is_elevated = new Delegate <pal_is_elevated_delegate>(_libPtr, osPlatform);
            pal_set_icon    = new Delegate <pal_set_icon_delegate>(_libPtr, osPlatform);

            // filesystem
            pal_fs_chmod       = new Delegate <pal_fs_chmod_delegate>(_libPtr, osPlatform);
            pal_fs_file_exists = new Delegate <pal_fs_file_exists_delegate>(_libPtr, osPlatform);
        }
예제 #13
0
        public static async Task <Device> Create(string deviceID, string orgID)
        {
            OSPlatform platform = OSUtils.GetPlatform();

            var systemDrive = DriveInfo.GetDrives().FirstOrDefault(x =>
                                                                   x.IsReady &&
                                                                   x.RootDirectory.FullName.Contains(Path.GetPathRoot(Environment.SystemDirectory ?? Environment.CurrentDirectory)));

            var device = new Device()
            {
                ID             = deviceID,
                DeviceName     = Environment.MachineName,
                Platform       = platform.ToString(),
                ProcessorCount = Environment.ProcessorCount,
                OSArchitecture = RuntimeInformation.OSArchitecture,
                OSDescription  = RuntimeInformation.OSDescription,
                Is64Bit        = Environment.Is64BitOperatingSystem,
                IsOnline       = true,
                Drives         = DriveInfo.GetDrives().Where(x => x.IsReady).Select(x => new Drive()
                {
                    DriveFormat   = x.DriveFormat,
                    DriveType     = x.DriveType,
                    Name          = x.Name,
                    RootDirectory = x.RootDirectory.FullName,
                    FreeSpace     = x.TotalSize > 0 ? x.TotalFreeSpace / x.TotalSize : 0,
                    TotalSize     = x.TotalSize > 0 ? Math.Round((double)(x.TotalSize / 1024 / 1024 / 1024), 2) : 0,
                    VolumeLabel   = x.VolumeLabel
                }).ToList(),
                OrganizationID = orgID,
                CurrentUser    = DeviceInformation.GetCurrentUser()
            };

            if (systemDrive != null && systemDrive.TotalSize > 0 && systemDrive.TotalFreeSpace > 0)
            {
                device.TotalStorage = Math.Round((double)(systemDrive.TotalSize / 1024 / 1024 / 1024), 2);
                device.UsedStorage  = Math.Round((double)((systemDrive.TotalSize - systemDrive.TotalFreeSpace) / 1024 / 1024 / 1024), 2);
            }


            var(usedMemory, totalMemory) = GetMemoryInGB();
            device.UsedMemory            = usedMemory;
            device.TotalMemory           = totalMemory;

            device.CpuUtilization = await GetCpuUtilization();

            if (File.Exists("Remotely_Agent.dll"))
            {
                device.AgentVersion = FileVersionInfo.GetVersionInfo("Remotely_Agent.dll")?.FileVersion?.ToString()?.Trim();
            }

            return(device);
        }
        protected virtual ServiceManager CreateServiceManager()
        {
            var sm = new ServiceManager();

            var platform = new OSPlatform();

            sm
            .AddService(TestLogger)
            .AddService(platform)
            .AddService(new FileSystem(platform));

            return(sm);
        }
예제 #15
0
        public static string[] GetPortNames()
        {
#if NETCOREAPP
            return(OperatingSystem.IsLinux() ? GetPortNames_Linux()
                : OperatingSystem.IsMacOS() ? GetPortNames_OSX()
                : OperatingSystem.IsFreeBSD() ? GetPortNames_FreeBSD()
#else
            return RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? GetPortNames_Linux()
                : RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? GetPortNames_OSX()
                : RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")) ? GetPortNames_FreeBSD()
#endif
                : throw new PlatformNotSupportedException(SR.PlatformNotSupported_SerialPort_GetPortNames));
        }
예제 #16
0
    private void InitializeControls()
    {
        OSPlatform platform = ProcessUtils.GetOSPlatform();

        if (platform != OSPlatform.Linux)
        {
            ButtonCopyClipboard = AddButton("Copy to Clipboard", Icons.Streams.PadNote);
        }
        ButtonSave = AddButton("Save", Icons.Streams.Save);

        AddSeparator();
        ButtonClose = AddButton("Close Snapshot", Icons.Streams.Delete);
    }
        public static int[] GetFieldOffsets(OSPlatform platform, bool is64Bit, NativeCapabilities nativeCapabilities)
        {
            var fieldTypes = new RfbType[FieldTypes.Length];

            Array.Copy(FieldTypes, fieldTypes, fieldTypes.Length);

            if (nativeCapabilities.HaveWin32Threads)
            {
                fieldTypes[(int)RfbScreenInfoPtrField.CursorMutex] = RfbType.Win32Mutex;
            }

            return(NativeLayout.GetFieldOffsets(fieldTypes, platform, is64Bit));
        }
예제 #18
0
        private static HttpMessageHandler CreateDefaultHandler()
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")))
            {
                return(new HttpClientHandler());
            }

#if NETCOREAPP
            return(new SocketsHttpHandler());
#else
            return(new HttpClientHandler());
#endif
        }
예제 #19
0
        public void Configure(IBlazorApplicationBuilder app)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")))
            {
                // Needed because the test server runs on a different port than the client app,
                // and we want to test sending/receiving cookies underling this config
                BrowserHttpMessageHandler.DefaultCredentials = FetchCredentialsOption.Include;

                GC.KeepAlive(ActivateMonoJSRuntime.EnsureActivated());
            }

            app.AddComponent <Index>("root");
        }
예제 #20
0
        public void CheckOSX()
        {
            Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.OSX));
            Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Create("OSX")));

            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("osx")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("mac")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("DARWIN")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("MACOSX")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
        }
예제 #21
0
        protected override ITarget GetTarget()
        {
            _dataTarget = DataTarget.LoadDump(DumpFile);

            OSPlatform targetPlatform = _dataTarget.DataReader.TargetPlatform;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                targetPlatform = OSPlatform.OSX;
            }
            _symbolService.AddDirectoryPath(Path.GetDirectoryName(DumpFile));
            return(new TargetFromDataReader(_dataTarget.DataReader, targetPlatform, this, _targetIdFactory++, DumpFile));
        }
예제 #22
0
        public ICpuMetrics GetCpuMetricsCollector(OSPlatform osPlatform)
        {
            if (osPlatform == OSPlatform.Windows)
            {
                return(new WindowsCpuMetrics());
            }
            else if (osPlatform == OSPlatform.Linux)
            {
                return(new LinuxCpuMetrics(new LinuxCommandsHelper(), new LinuxCpuMetricsHelpers()));
            }

            throw new PlatformNotSupportedException($"Not supported platform {osPlatform}");
        }
예제 #23
0
 [Fact, PlatformSpecific(TestPlatforms.Windows)]  // Tests RuntimeInformation OS platform
 public void CheckWindows()
 {
     Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
     Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Create("WINDOWS")));
     Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")));
     Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")));
     Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NetBSD")));
     Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("netbsd")));
     Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
     Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.OSX));
     Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("windows")));
     Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("Windows NT")));
 }
예제 #24
0
        public void CheckLinux()
        {
            Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
            Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Create("LINUX")));

            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("linux")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("UNIX")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("DARWIN")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("ubuntu")));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
            Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.OSX));
        }
예제 #25
0
        static ClipboardService()
        {
#if NET5_0
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("Browser")))
            {
                throw new($"The static class ClipboardService is not supported on Blazor. Instead inject an {nameof(IClipboard)} using {nameof(ServiceExtensions)}{nameof(ServiceExtensions.InjectClipboard)}.");
            }
#endif
            getAsyncFunc   = CreateAsyncGet();
            getFunc        = CreateGet();
            setAsyncAction = CreateAsyncSet();
            setAction      = CreateSet();
        }
예제 #26
0
        string BuildRuntimeIdentifier()
        {
            string rid;

            if (OSPlatform == OSPlatform.Windows)
            {
                rid = "win";
            }
            else if (OSPlatform == OSPlatform.OSX)
            {
                rid = "osx";
            }
            else if (OSPlatform == OSPlatform.Linux)
            {
                rid = "linux";
            }
            else
            {
                rid = OSPlatform.ToString().ToLowerInvariant();
            }

            if (Architecture == null)
            {
                return(rid);
            }

            switch (Architecture.Value)
            {
            case X86:
                rid += "-x86";
                break;

            case X64:
                rid += "-x64";
                break;

            case Arm:
                rid += "-arm";
                break;

            case Arm64:
                rid += "-arm64";
                break;

            default:
                rid += "-" + Architecture.Value.ToString().ToLowerInvariant();
                break;
            }

            return(rid);
        }
예제 #27
0
        InstallerPhase InstallPackage(string package_filename)
        {
            OSPlatform p = OSPlatform.x86;

            if (InstallerEngine.Is64BitProcess())
            {
                p = OSPlatform.x64;
            }

            string quotedFile = package_filename.Trim("\"".ToCharArray());

            Logger.Log(LogLevel.Info, string.Format("Installing Package: '{0}'", package_filename));
            return(Program.ExecuteChildProcess(p, "\"" + quotedFile + "\"", true));
        }
예제 #28
0
 public static bool TestPlatformApplies(TestPlatforms platforms) =>
 (platforms.HasFlag(TestPlatforms.Any)) ||
 (platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) ||
 (platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ||
 (platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) ||
 (platforms.HasFlag(TestPlatforms.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ||
 (platforms.HasFlag(TestPlatforms.illumos) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("ILLUMOS"))) ||
 (platforms.HasFlag(TestPlatforms.Solaris) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("SOLARIS"))) ||
 (platforms.HasFlag(TestPlatforms.iOS) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS"))) ||
 (platforms.HasFlag(TestPlatforms.tvOS) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS"))) ||
 (platforms.HasFlag(TestPlatforms.MacCatalyst) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("MACCATALYST"))) ||
 (platforms.HasFlag(TestPlatforms.Android) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID"))) ||
 (platforms.HasFlag(TestPlatforms.Browser) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER"))) ||
 (platforms.HasFlag(TestPlatforms.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
예제 #29
0
        /// <summary>
        /// Returns the file name of the DAC dll according to the specified parameters.
        /// </summary>
        public static string GetDacFileName(ClrFlavor flavor, OSPlatform platform)
        {
            if (platform == OSPlatform.Linux)
            {
                return(c_linuxCoreDacFileName);
            }

            if (platform == OSPlatform.OSX)
            {
                return(c_macOSCoreDacFileName);
            }

            return(flavor == ClrFlavor.Core ? c_coreDacFileName : c_desktopDacFileName);
        }
예제 #30
0
        public static OSPlatform GetOSPlatform()
        {
            OSPlatform result = OSPlatform.OSX;

            if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                result = OSPlatform.Windows;
            }
            else if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                result = OSPlatform.Linux;
            }
            return(result);
        }
예제 #31
0
		public static bool IsOSPlatform (OSPlatform osPlatform)
		{
			switch (Environment.OSVersion.Platform) {
			case PlatformID.Win32NT:
				return osPlatform == OSPlatform.Windows;
			case PlatformID.Unix:
				if (File.Exists ("/usr/lib/libc.dylib"))
					return osPlatform == OSPlatform.OSX;

				return osPlatform == OSPlatform.Linux;
			default:
				return false;
			}
		}
        protected ServiceManager CreateServiceManager()
        {
            Services = new ServiceManager();

            var platform = new OSPlatform();

            Services
            .AddService(TestLogger)
            .AddService(platform)
            .AddService(new ProcessServices())
            .AddService(new FileSystem(platform));

            return(Services);
        }
예제 #33
0
 public ShellService(IEnvironmentService envService)
 {
     OS = envService.OSType();
     if (OS == OSPlatform.Windows)
     {
         cmdString   = "cmd.exe";
         cmdArgument = "/c";
     }
     else
     {
         cmdString   = "/bin/bash";
         cmdArgument = "-c";
     }
 }
예제 #34
0
        private void TestPlatform(string brokerSubPath, string hostSubPath, OSPlatform platform)
        {
            var locator    = new BrokerExecutableLocator(_fs, platform);
            var brokerPath = Path.Combine(locator.BaseDirectory, brokerSubPath);
            var hostPath   = Path.Combine(locator.BaseDirectory, hostSubPath);

            _fs.FileExists(brokerPath).Returns(true);
            locator.GetBrokerExecutablePath().Should().Be(brokerPath);
            locator.GetHostExecutablePath().Should().BeNull();

            _fs.FileExists(hostPath).Returns(true);
            locator.GetBrokerExecutablePath().Should().Be(brokerPath);
            locator.GetHostExecutablePath().Should().Be(hostPath);
        }
예제 #35
0
		public static bool IsOSPlatform (OSPlatform osPlatform)
		{
			// TODO: very barebones implementation

			if (Environment.OSVersion.Platform == PlatformID.Win32NT)
				return osPlatform == OSPlatform.Windows;

			if (Environment.OSVersion.Platform == PlatformID.Unix && File.Exists ("/usr/lib/libc.dylib"))
				return osPlatform == OSPlatform.OSX;

			if (Environment.OSVersion.Platform == PlatformID.Unix)
				return osPlatform == OSPlatform.Linux;

			return false;
		}
예제 #36
0
 public static bool IsOSPlatform(OSPlatform osPlatform)
 {
     return OSPlatform.Linux == osPlatform;
 }
예제 #37
0
파일: RhinoInfo.cs 프로젝트: Crae/rhiexec
        public void Inspect(string PathToRhino)
        {
            Logger.Log(LogLevel.Debug, "InspectRhino\tConstructing new RhinoInfo: " + PathToRhino);
              RhinoExePath = PathToRhino;
              if (IntPtr.Size == 4)
            OS = OSPlatform.x86;
              else if (IntPtr.Size == 8)
            OS = OSPlatform.x64;

              AssemblyResolver.AddSearchPath(RhinoExePath, true);
              GetRhinoDotNetVersion();
              GetRhinoCommonVersion();
              GetCppSdkVersions();
        }
예제 #38
0
 public static bool IsOSPlatform(OSPlatform osPlatform)
 {
     return s_freeBSD == osPlatform;
 }
예제 #39
0
        private void ReadXml101(XmlDocument doc)
        {
            XmlNode package = doc.SelectSingleNode("/RhinoInstaller/Package");
              if (package == null)
            return;

              this.VersionNumber = new Version(XmlHelper.SelectSingleNodeInnerText(package, "Version"));
              this.Title = XmlHelper.SelectSingleNodeInnerText(package, "Title");

              // GUID
              string sGuid = XmlHelper.SelectSingleNodeInnerText(package, "ID");
              try
              {
            this.ID = new Guid(sGuid);
              }
              catch
              {
            throw new PackageAuthoringException(string.Format("GUID malformed: '{0}'", sGuid));
              }

              this.UpdateUrl = XmlHelper.SelectSingleNodeInnerText(package, "UpdateUrl");
              string os = XmlHelper.SelectSingleNodeInnerText(package, "OS");
              try
              {
            OS = (OSPlatform)Enum.Parse(OS.GetType(), os);
              }
              catch
              {
            throw new InvalidOperatingSystemException(os);
              }

              XmlNode contentType = package.SelectSingleNode("ContentType");
              if (contentType != null)
              {
            this.ContentType = PackageContentType.Unknown;
            PackageContentType t;
            if (Enum.TryParse(contentType.InnerText, out t))
            {
              this.ContentType = t;
            }
              }

              // Platform, if it exists
              XmlNodeList platforms = package.SelectNodes("RhinoPlatform");
              if (platforms != null)
              {
            foreach (XmlNode platform in platforms)
            {
              RhinoPlatform p = RhinoPlatform.Unknown;
              p = (RhinoPlatform) Enum.Parse(p.GetType(), platform.InnerText);
              if (p != RhinoPlatform.Unknown)
            SupportedPlatforms.Add(p);
            }
              }

              // Culture, if it exists
              XmlNode culture = package.SelectSingleNode("Locale");
              if (null != culture)
              {
            if ( 0 != System.String.CompareOrdinal(culture.InnerText.ToUpperInvariant(), "LOCALEINVARIANT")
              && 0 != System.String.CompareOrdinal(culture.InnerText.ToUpperInvariant(), "UNKNOWN") )
            {
              Locale = new CultureInfo(culture.InnerText);
            }
              }

              ReadFromDocument(package);
        }
 public static bool IsOSPlatform(OSPlatform osPlatform)
 {
     throw new PlatformNotSupportedException();
 }
예제 #41
0
 public static bool IsOSPlatform(OSPlatform osPlatform)
 {
     return OSPlatform.Windows == osPlatform;
 }
예제 #42
0
 public static bool IsOSPlatform(OSPlatform osPlatform)
 {
     string name = s_osPlatformName ?? (s_osPlatformName = Interop.Sys.GetUnixName());
     return osPlatform.Equals(name);
 }
예제 #43
0
파일: RhinoInfo.cs 프로젝트: Crae/rhiexec
        public bool ReadXml(string XmlPath)
        {
            Logger.Log(LogLevel.Debug, "InspectRhino\tReadXml: " + XmlPath);

              XmlDocument doc = new XmlDocument();
              doc.Load(XmlPath);

              XmlNode node = doc.SelectSingleNode("/RhinoExeInfo");
              if (node == null)
            return false;

              if (node.Attributes == null)
            return false;

              XmlAttribute verAttr = node.Attributes["Version"];
              if (verAttr == null)
            return false;

              string version = verAttr.Value;
              if (version != "1.0.1")
            return false;

              XmlNode exeinfo = doc.SelectSingleNode("/RhinoExeInfo");

              RhinoVersion = new Version(XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoVersion", XmlPath));
              RhinoSdkVersion = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoSdkVersion", XmlPath);
              Edition = XmlHelper.SelectSingleNodeInnerText(exeinfo, "Edition", XmlPath);
              RhinoSdkServiceRelease = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoSdkServiceRelease", XmlPath);
              RhinoDotNetVersion = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoDotNetVersion", XmlPath);
              RhinoCommonVersion = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoCommonVersion", XmlPath);
              RhinoExePath = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoExePath", XmlPath);

              string platform = XmlHelper.SelectSingleNodeInnerText(exeinfo, "OSPlatform", XmlPath);

              try
              {
            OS = (OSPlatform)Enum.Parse(OS.GetType(), platform);
              }
              catch
              {
            throw new InvalidOperatingSystemException("Unsupported OS Platform: " + platform);
              }

              return true;
        }