Exemplo n.º 1
0
        public static DeviceInfo[] ListDevices(string dicRemote = null)
        {
            if (dicRemote is null)
            {
                switch (DetectOS.GetRealPlatformID())
                {
                case PlatformID.Win32NT: return(Windows.ListDevices.GetList());

                case PlatformID.Linux: return(Linux.ListDevices.GetList());

                case PlatformID.FreeBSD: return(FreeBSD.ListDevices.GetList());

                default:
                    throw new InvalidOperationException(
                              $"Platform {DetectOS.GetRealPlatformID()} not yet supported.");
                }
            }

            try
            {
                using (var remote = new Remote.Remote(dicRemote))
                {
                    return(remote.ListDevices());
                }
            }
            catch (Exception)
            {
                DicConsole.ErrorWriteLine("Error connecting to host.");
                return(new DeviceInfo[0]);
            }
        }
Exemplo n.º 2
0
        public static DeviceInfo[] ListDevices(out bool isRemote, out string serverApplication,
                                               out string serverVersion, out string serverOperatingSystem,
                                               out string serverOperatingSystemVersion, out string serverArchitecture,
                                               string dicRemote = null)
        {
            isRemote                     = false;
            serverApplication            = null;
            serverVersion                = null;
            serverOperatingSystem        = null;
            serverOperatingSystemVersion = null;
            serverArchitecture           = null;

            if (dicRemote is null)
            {
                switch (DetectOS.GetRealPlatformID())
                {
                case PlatformID.Win32NT: return(Windows.ListDevices.GetList());

                case PlatformID.Linux:   return(Linux.ListDevices.GetList());

                case PlatformID.FreeBSD: return(FreeBSD.ListDevices.GetList());

                default:
                    throw new
                          InvalidOperationException($"Platform {DetectOS.GetRealPlatformID()} not yet supported.");
                }
            }

            try
            {
                using (var remote = new Remote.Remote(dicRemote))
                {
                    isRemote                     = true;
                    serverApplication            = remote.ServerApplication;
                    serverVersion                = remote.ServerVersion;
                    serverOperatingSystem        = remote.ServerOperatingSystem;
                    serverOperatingSystemVersion = remote.ServerOperatingSystemVersion;
                    serverArchitecture           = remote.ServerArchitecture;

                    return(remote.ListDevices());
                }
            }
            catch (Exception)
            {
                DicConsole.ErrorWriteLine("Error connecting to host.");

                return(new DeviceInfo[0]);
            }
        }