Open() публичный Метод

public Open ( string path, bool @abstract ) : void
path string
@abstract bool
Результат void
Пример #1
0
        public static Transport Create(AddressEntry entry)
        {
            switch (entry.Method)
            {
            case "tcp":
            {
                Transport transport = new SocketTransport();
                transport.Open(entry);
                return(transport);
            }

#if !PORTABLE
            case "unix":
            {
                Transport transport = new UnixNativeTransport();
                transport.Open(entry);
                return(transport);
            }
#endif
#if ENABLE_PIPES
            case "win": {
                Transport transport = new PipeTransport();
                transport.Open(entry);
                return(transport);
            }
#endif
            default:
                throw new NotSupportedException("Transport method \"" + entry.Method + "\" not supported");
            }
        }
Пример #2
0
 public static Transport Create(AddressEntry entry)
 {
     switch (entry.Method) {
         case "tcp":
         {
             Transport transport = new SocketTransport ();
             transport.Open (entry);
             return transport;
         }
     #if !PORTABLE
         case "unix":
         {
             Transport transport = new UnixNativeTransport ();
             transport.Open (entry);
             return transport;
         }
     #endif
     #if ENABLE_PIPES
         case "win": {
             Transport transport = new PipeTransport ();
             transport.Open (entry);
             return transport;
         }
     #endif
         default:
             throw new NotSupportedException ("Transport method \"" + entry.Method + "\" not supported");
     }
 }
Пример #3
0
        public static Transport Create(AddressEntry entry)
        {
            switch (entry.Method) {
                case "tcp":
                {
                    Transport transport = new SocketTransport ();
                    transport.Open (entry);
                    return transport;
                }

                case "unix":
                {
                    if (OSHelpers.PlatformIsUnixoid) {
                        Transport transport = new UnixNativeTransport ();
                        transport.Open (entry);
                        return transport;
                    }
                    break;
                }

            #if ENABLE_PIPES
                case "win":
                {
                    Transport transport = new PipeTransport ();
                    transport.Open (entry);
                    return transport;
                }
            #endif

                // "autolaunch:" means: the first client user of the dbus library shall spawn the daemon on itself, see dbus 1.7.8 from http://dbus.freedesktop.org/releases/dbus/
                case "autolaunch":
                {
                    if (OSHelpers.PlatformIsUnixoid)
                        break;

                    string addr = Address.GetSessionBusAddressFromSharedMemory ();

                    if (string.IsNullOrEmpty (addr)) { // we have to launch the daemon ourselves
                        string oldDir = Directory.GetCurrentDirectory ();
                        // Without this, the "current" folder for the new process will be the one where the current
                        // executable resides, and as a consequence,that folder cannot be relocated/deleted unless the daemon is stopped
                        Directory.SetCurrentDirectory (Environment.GetFolderPath (Environment.SpecialFolder.System));

                        Process process = Process.Start (DBUS_DAEMON_LAUNCH_COMMAND);
                        if (process == null) {
                            Directory.SetCurrentDirectory (oldDir);
                            throw new NotSupportedException ("Transport method \"autolaunch:\" - cannot launch dbus daemon '" + DBUS_DAEMON_LAUNCH_COMMAND + "'");
                        }

                        // wait for daemon
                        Stopwatch stopwatch = new Stopwatch ();
                        stopwatch.Start ();
                        do {
                            addr = Address.GetSessionBusAddressFromSharedMemory ();
                            if (String.IsNullOrEmpty (addr))
                                Thread.Sleep (100);
                        } while (String.IsNullOrEmpty (addr) && stopwatch.ElapsedMilliseconds <= 5000);

                        Directory.SetCurrentDirectory (oldDir);
                    }

                    if (string.IsNullOrEmpty (addr))
                        throw new NotSupportedException ("Transport method \"autolaunch:\" - timeout during access to freshly launched dbus daemon");
                    return Create (AddressEntry.Parse (addr));
                }

            }

            throw new NotSupportedException ("Transport method \"" + entry.Method + "\" not supported");
        }
Пример #4
0
        public static Transport Create(AddressEntry entry)
        {
            switch (entry.Method)
            {
            case "tcp":
            {
                Transport transport = new SocketTransport();
                transport.Open(entry);
                return(transport);
            }

            case "unix":
            {
                if (OSHelpers.PlatformIsUnixoid)
                {
                    Transport transport = new UnixNativeTransport();
                    transport.Open(entry);
                    return(transport);
                }
                break;
            }

#if ENABLE_PIPES
            case "win":
            {
                Transport transport = new PipeTransport();
                transport.Open(entry);
                return(transport);
            }
#endif

            // "autolaunch:" means: the first client user of the dbus library shall spawn the daemon on itself, see dbus 1.7.8 from http://dbus.freedesktop.org/releases/dbus/
            case "autolaunch":
            {
                if (OSHelpers.PlatformIsUnixoid)
                {
                    break;
                }

                string addr = Address.GetSessionBusAddressFromSharedMemory();

                if (string.IsNullOrEmpty(addr))                            // we have to launch the daemon ourselves
                {
                    string oldDir = Directory.GetCurrentDirectory();
                    // Without this, the "current" folder for the new process will be the one where the current
                    // executable resides, and as a consequence,that folder cannot be relocated/deleted unless the daemon is stopped
                    Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.System));

                    Process process = Process.Start(DBUS_DAEMON_LAUNCH_COMMAND);
                    if (process == null)
                    {
                        Directory.SetCurrentDirectory(oldDir);
                        throw new NotSupportedException("Transport method \"autolaunch:\" - cannot launch dbus daemon '" + DBUS_DAEMON_LAUNCH_COMMAND + "'");
                    }

                    // wait for daemon
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    do
                    {
                        addr = Address.GetSessionBusAddressFromSharedMemory();
                        if (String.IsNullOrEmpty(addr))
                        {
                            Thread.Sleep(100);
                        }
                    } while (String.IsNullOrEmpty(addr) && stopwatch.ElapsedMilliseconds <= 5000);

                    Directory.SetCurrentDirectory(oldDir);
                }

                if (string.IsNullOrEmpty(addr))
                {
                    throw new NotSupportedException("Transport method \"autolaunch:\" - timeout during access to freshly launched dbus daemon");
                }
                return(Create(AddressEntry.Parse(addr)));
            }
            }

            throw new NotSupportedException("Transport method \"" + entry.Method + "\" not supported");
        }