Example #1
0
        public static AddressEntry Parse(string s)
        {
            AddressEntry entry = new AddressEntry();

            string[] parts = s.Split(':');

            if (parts.Length < 2)
            {
                throw new BadAddressException("No colon found");
            }
            if (parts.Length > 2)
            {
                throw new BadAddressException("Too many colons found");
            }

            entry.Method = parts[0];

            foreach (string propStr in parts[1].Split(','))
            {
                parts = propStr.Split('=');

                if (parts.Length < 2)
                {
                    throw new BadAddressException("No equals sign found");
                }
                if (parts.Length > 2)
                {
                    throw new BadAddressException("Too many equals signs found");
                }

                entry.Properties[parts[0]] = Unescape(parts[1]);
            }

            return(entry);
        }
Example #2
0
		public static AddressEntry Parse (string s)
		{
			AddressEntry entry = new AddressEntry ();

			string[] parts = s.Split (':');

			if (parts.Length < 2)
				throw new BadAddressException ("No colon found");
			if (parts.Length > 2)
				throw new BadAddressException ("Too many colons found");

			entry.Method = parts[0];

			foreach (string propStr in parts[1].Split (',')) {
				parts = propStr.Split ('=');

				if (parts.Length < 2)
					throw new BadAddressException ("No equals sign found");
				if (parts.Length > 2)
					throw new BadAddressException ("Too many equals signs found");

				entry.Properties[parts[0]] = Unescape (parts[1]);
			}

			return entry;
		}
Example #3
0
        public TcpServer(string address)
        {
            AddressEntry[] entries = NDesk.DBus.Address.Parse(address);
            AddressEntry   entry   = entries[0];

            if (entry.Method != "tcp")
            {
                throw new Exception();
            }

            string val;

            if (entry.Properties.TryGetValue("port", out val))
            {
                port = UInt32.Parse(val);
            }

            if (entry.GUID == UUID.Zero)
            {
                entry.GUID = UUID.Generate();
            }
            Id = entry.GUID;

            /*
             * Id = entry.GUID;
             * if (Id == UUID.Zero)
             *      Id = UUID.Generate ();
             */

            this.address = entry.ToString();
            //Console.WriteLine ("Server address: " + Address);
        }
Example #4
0
        //(unix:(path|abstract)=.*,guid=.*|tcp:host=.*(,port=.*)?);? ...
        public static AddressEntry[] Parse(string addresses)
        {
            if (addresses == null)
            {
                throw new ArgumentNullException(addresses);
            }

            List <AddressEntry> entries = new List <AddressEntry> ();

            foreach (string entryStr in addresses.Split(';'))
            {
                entries.Add(AddressEntry.Parse(entryStr));
            }

            return(entries.ToArray());
        }
Example #5
0
        public static AddressEntry Parse(string s)
        {
            AddressEntry entry = new AddressEntry();

            string[] parts = s.Split(':');

            if (parts.Length < 2)
            {
                throw new InvalidAddressException("No colon found");
            }
            if (parts.Length > 2)
            {
                throw new InvalidAddressException("Too many colons found");
            }

            entry.Method = parts[0];

            foreach (string propStr in parts[1].Split(','))
            {
                parts = propStr.Split('=');

                if (parts.Length < 2)
                {
                    throw new InvalidAddressException("No equals sign found");
                }
                if (parts.Length > 2)
                {
                    throw new InvalidAddressException("Too many equals signs found");
                }

                if (parts[0] == "guid")
                {
                    try {
                        entry.GUID = UUID.Parse(parts[1]);
                    } catch {
                        throw new InvalidAddressException("Invalid guid specified");
                    }
                    continue;
                }

                entry.Properties[parts[0]] = Unescape(parts[1]);
            }

            return(entry);
        }
Example #6
0
        public UnixServer(string address)
        {
            AddressEntry[] entries = NDesk.DBus.Address.Parse(address);
            AddressEntry   entry   = entries[0];

            if (entry.Method != "unix")
            {
                throw new Exception();
            }

            string val;

            if (entry.Properties.TryGetValue("path", out val))
            {
                unixPath   = val;
                isAbstract = false;
            }
            else if (entry.Properties.TryGetValue("abstract", out val))
            {
                unixPath   = val;
                isAbstract = true;
            }

            if (String.IsNullOrEmpty(unixPath))
            {
                throw new Exception("Address path is invalid");
            }

            if (entry.GUID == UUID.Zero)
            {
                entry.GUID = UUID.Generate();
            }
            Id = entry.GUID;

            /*
             * Id = entry.GUID;
             * if (Id == UUID.Zero)
             *      Id = UUID.Generate ();
             */

            this.address = entry.ToString();
            //Console.WriteLine ("Server address: " + Address);
        }
Example #7
0
        internal void OpenPrivate(string address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }

            AddressEntry[] entries = Address.Parse(address);
            if (entries.Length == 0)
            {
                throw new Exception("No addresses were found");
            }

            //TODO: try alternative addresses if needed
            AddressEntry entry = entries[0];

            Id          = entry.GUID;
            Transport   = Transport.Create(entry);
            isConnected = true;
        }
Example #8
0
        internal void OpenPrivate(string address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }

            AddressEntry[] entries = Address.Parse(address);
            if (entries.Length == 0)
            {
                throw new Exception("No addresses were found");
            }

            //TODO: try alternative addresses if needed
            AddressEntry entry = entries[0];

            transport = Transport.Create(entry);

            //TODO: clean this bit up
            ns = transport.Stream;
        }
Example #9
0
        public WinServer(string address)
        {
            AddressEntry[] entries = NDesk.DBus.Address.Parse(address);
            AddressEntry   entry   = entries[0];

            if (entry.Method != "win")
            {
                throw new Exception();
            }

            string val;

            if (entry.Properties.TryGetValue("path", out val))
            {
                pipePath = val;
            }

            if (String.IsNullOrEmpty(pipePath))
            {
                throw new Exception("Address path is invalid");
            }

            if (entry.GUID == UUID.Zero)
            {
                entry.GUID = UUID.Generate();
            }
            Id = entry.GUID;

            /*
             * Id = entry.GUID;
             * if (Id == UUID.Zero)
             *      Id = UUID.Generate ();
             */

            this.address = entry.ToString();
            Console.WriteLine("Server address: " + Address);
        }
Example #10
0
 public override void Open(NDesk.DBus.AddressEntry entry)
 {
 }